Merged V3.2 to HEAD

17410: Merged V3.1 to V3.2
      16667: (record-only) Fix ETHREEOH-2477 - group-based perms (MT env)
      16883: Fix ETHREEOH-1544 - cannot paste an item, if cut from another web project (modifyLock errror)
      16918: Fix ETHREEOH-3053 - Deployment of non-stale file in a stale layered folder removes the file from FSR
      16947: (record-only) Temporarily comment-out testSubmitChangedAssets1 (intermittent permission failure)
      17162: Fix ETHREEOH-2850 - submitting delete of (web form) xml instance does not submit the associated deleted renditions
      17319: Fix ETHREEOH-3111 - ManageReviewTaskDialog (fix-up contributed patch)
   17418: Merged V3.1 to V3.2
      17141: Fix ETHREEOH-3088: Cut/Paste into self causes stack overflow
      17216: Fixed ETHREEOH-3170: DB errors on MSSQL with Snapshot Isolation enabled while CIFS copying
      17255: Fixed ETHREEOH-3180: Error appears when trying to search resources on Manage Task page
   17419: Fix for ETHREEOH-3296: Enterprise 3.X / Permissions Error When Cut & Paste on Sub-Folder
   17421: Review and tweaks of DB script port
   17423: Follow-on for ETHREEOH-3088
   17424: Missed check-in for ETHREEOH-3032 (CHK-10240)
   17437: ETHREEOH-2790 - OpenOffice-startup-context.xml needs to also initiate the connection to OpenOffice
   17441: Build fix: Fix AVM permission inheritance to match DM and fix common permission dao component
   17470: Fix for ETHREEOH-3350: Admin Console - Viewing user properties for user without home folder throws exception
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /alfresco/BRANCHES/V3.1:r16667,16883,16918,16947,17141,17162,17216,17255,17319
   Merged /alfresco/BRANCHES/V3.2:r17410,17418-17419,17421,17423-17424,17437,17441,17470


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18137 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2010-01-19 13:18:50 +00:00
parent a5c09bb7c1
commit e80a27b73c
6 changed files with 539 additions and 522 deletions

View File

@@ -64,7 +64,7 @@ public class ManageReviewTaskDialog extends ManageTaskDialog
protected String webapp; protected String webapp;
protected NodeRef webProjectRef; protected NodeRef webProjectRef;
protected AVMBrowseBean avmBrowseBean; protected AVMBrowseBean avmBrowseBean;
transient protected PermissionService permissionService; transient private PermissionService permissionService;
private static final Log logger = LogFactory.getLog(ManageReviewTaskDialog.class); private static final Log logger = LogFactory.getLog(ManageReviewTaskDialog.class);

View File

@@ -65,9 +65,7 @@ import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.forms.Form;
import org.alfresco.web.forms.FormInstanceData; import org.alfresco.web.forms.FormInstanceData;
import org.alfresco.web.forms.FormNotFoundException;
import org.alfresco.web.forms.FormsService; import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.Rendition; import org.alfresco.web.forms.Rendition;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
@@ -737,81 +735,63 @@ public class SubmitDialog extends BaseDialogBean
this.warningItems.add(new ItemWrapper(node)); this.warningItems.add(new ItemWrapper(node));
continue; continue;
} }
NodeRef ref = AVMNodeConverter.ToNodeRef(-1, node.getPath()); NodeRef ref = AVMNodeConverter.ToNodeRef(-1, node.getPath());
if (submittedPaths.contains(node.getPath())) if (submittedPaths.contains(node.getPath()))
{ {
continue; continue;
} }
if (node.isDeleted())
{
// found a deleted node for submit
this.submitItems.add(new ItemWrapper(node));
submittedPaths.add(node.getPath());
}
// lookup if this item was created via a form - then lookup the workflow defaults boolean isForm = getNodeService().hasAspect(ref, WCMAppModel.ASPECT_FORM_INSTANCE_DATA);
// for that form and store into the list of available workflows boolean isRendition = getNodeService().hasAspect(ref, WCMAppModel.ASPECT_RENDITION);
else if (!getNodeService().hasAspect(ref, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
if (((!isForm) && (!isRendition)) || (node.isDeleted() && (!isForm)))
{ {
// found single item for submit
// note: could be a single deleted rendition - to enable deletion of old renditions (eg. if template no longer applicable)
this.submitItems.add(new ItemWrapper(node)); this.submitItems.add(new ItemWrapper(node));
submittedPaths.add(node.getPath()); submittedPaths.add(node.getPath());
} }
else else
{ {
// item is a form (note: could be deleted) or a rendition
FormInstanceData fid = null; FormInstanceData fid = null;
// check if this is a rendition - as they also have the forminstancedata aspect if (isRendition)
if (getNodeService().hasAspect(ref, WCMAppModel.ASPECT_RENDITION))
{ {
// found a generated rendition asset - locate the parent form instance data file // found a generated rendition asset - locate the parent form instance data file
// and use this to find all generated assets that are appropriate // and use this to find all generated assets that are appropriate
// NOTE: this path value is store relative // NOTE: this path value is store relative
fid = getFormsService().getRendition(ref).getPrimaryFormInstanceData(); fid = getFormsService().getRendition(ref).getPrimaryFormInstanceData(true);
} }
else else
{ {
fid = getFormsService().getFormInstanceData(ref); 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 // add the form instance data file to the list for submission
if (!submittedPaths.contains(fid.getPath())) if (!submittedPaths.contains(fid.getPath()))
{ {
this.submitItems.add(new ItemWrapper(getAvmService().lookup(-1, fid.getPath()))); this.submitItems.add(new ItemWrapper(getAvmService().lookup(-1, fid.getPath(), true)));
submittedPaths.add(fid.getPath()); submittedPaths.add(fid.getPath());
} }
// locate renditions for this form instance data file and add to list for submission // locate renditions for this form instance data file and add to list for submission
for (final Rendition rendition : fid.getRenditions()) for (final Rendition rendition : fid.getRenditions(true))
{ {
final String renditionPath = rendition.getPath(); final String renditionPath = rendition.getPath();
if (!submittedPaths.contains(renditionPath)) if (!submittedPaths.contains(renditionPath))
{ {
this.submitItems.add(new ItemWrapper(getAvmService().lookup(-1, renditionPath))); this.submitItems.add(new ItemWrapper(getAvmService().lookup(-1, renditionPath, true)));
submittedPaths.add(renditionPath); submittedPaths.add(renditionPath);
} }
} }
if (f != null) // lookup the workflow defaults for that form and store into the list of available workflows
WorkflowDefinition defaultWfDef = fid.getForm().getDefaultWorkflow();
if (defaultWfDef != null)
{ {
WorkflowDefinition defaultWfDef = f.getDefaultWorkflow(); this.workflows.add(new FormWorkflowWrapper(defaultWfDef.getName(),
if (defaultWfDef != null) fid.getForm().getDefaultWorkflowParameters()));
{
this.workflows.add(new FormWorkflowWrapper(defaultWfDef.getName(),
f.getDefaultWorkflowParameters()));
}
} }
// See WCM-1090 ACT-1551 // See WCM-1090 ACT-1551
@@ -825,14 +805,14 @@ public class SubmitDialog extends BaseDialogBean
} }
} }
} }
tx.commit(); tx.commit();
} }
catch (Throwable e) catch (Throwable e)
{ {
// rollback the transaction on error // rollback the transaction on error
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {} try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
// rethrow the exception to highlight the problem // rethrow the exception to highlight the problem
throw (RuntimeException)e; throw (RuntimeException)e;
} }
@@ -1106,4 +1086,4 @@ public class SubmitDialog extends BaseDialogBean
return descriptor.getPath().hashCode(); return descriptor.getPath().hashCode();
} }
} }
} }

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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -47,39 +47,39 @@ public interface FormInstanceData
private static final long serialVersionUID = -3827878774655260635L; private static final long serialVersionUID = -3827878774655260635L;
private final RenderingEngineTemplate ret; private final RenderingEngineTemplate ret;
private final String path; private final String path;
private final Rendition r; private final Rendition r;
private final Exception e; private final Exception e;
public RegenerateResult(final RenderingEngineTemplate ret, public RegenerateResult(final RenderingEngineTemplate ret,
final String path, final String path,
final Rendition r) final Rendition r)
{ {
this.ret = ret; this.ret = ret;
this.r = r; this.r = r;
this.e = null; this.e = null;
this.path = path; this.path = path;
} }
public RegenerateResult(final RenderingEngineTemplate ret, public RegenerateResult(final RenderingEngineTemplate ret,
final String path, final String path,
final Exception e) final Exception e)
{ {
this.ret = ret; this.ret = ret;
this.e = e; this.e = e;
this.r = null; this.r = null;
this.path = path; this.path = path;
} }
public RenderingEngineTemplate getRenderingEngineTemplate() public RenderingEngineTemplate getRenderingEngineTemplate()
{ {
return this.ret; return this.ret;
} }
public String getPath() public String getPath()
{ {
return this.path; return this.path;
} }
public Rendition getRendition() public Rendition getRendition()
{ {
@@ -123,4 +123,7 @@ public interface FormInstanceData
/** returns all renditions of this form instance data */ /** returns all renditions of this form instance data */
public List<Rendition> getRenditions(); public List<Rendition> getRenditions();
/** returns all renditions of this form instance data (include deleted AVM nodes) */
public List<Rendition> getRenditions(boolean includeDeleted);
} }

View File

@@ -1,381 +1,405 @@
/* /*
* Copyright (C) 2005-2009 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 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 * 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 * the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's * and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing * FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here: * the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" * http://www.alfresco.com/legal/licensing"
*/ */
package org.alfresco.web.forms; package org.alfresco.web.forms;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import org.alfresco.model.WCMAppModel; import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue; import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.locking.AVMLock; import org.alfresco.service.cmr.avm.locking.AVMLock;
import org.alfresco.service.cmr.avm.locking.AVMLockingService; import org.alfresco.service.cmr.avm.locking.AVMLockingService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.web.app.servlet.FacesHelper; import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.bean.wcm.AVMUtil;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
* Encapsulation of a rendition. * Encapsulation of a rendition.
* *
* @author Ariel Backenroth * @author Ariel Backenroth
*/ */
/* package */ class FormInstanceDataImpl implements FormInstanceData /* package */ class FormInstanceDataImpl implements FormInstanceData
{ {
private static final long serialVersionUID = -7806221587661854013L; private static final long serialVersionUID = -7806221587661854013L;
private static final Log logger = LogFactory.getLog(RenditionImpl.class); private static final Log logger = LogFactory.getLog(RenditionImpl.class);
private final NodeRef nodeRef; private final NodeRef nodeRef;
private transient FormsService formsService; private transient FormsService formsService;
/* package */ FormInstanceDataImpl(final NodeRef nodeRef, /* package */ FormInstanceDataImpl(final NodeRef nodeRef,
final FormsService formsService) final FormsService formsService)
{ {
if (nodeRef == null) if (nodeRef == null)
{ {
throw new NullPointerException(); throw new NullPointerException();
} }
if (formsService == null) if (formsService == null)
{ {
throw new NullPointerException(); throw new NullPointerException();
} }
final AVMService avmService = this.getServiceRegistry().getAVMService(); final AVMService avmService = this.getServiceRegistry().getAVMService();
if (!avmService.hasAspect(AVMNodeConverter.ToAVMVersionPath(nodeRef).getFirst(), if (!avmService.hasAspect(AVMNodeConverter.ToAVMVersionPath(nodeRef).getFirst(),
AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(), AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(),
WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
{ {
throw new IllegalArgumentException("node " + nodeRef + throw new IllegalArgumentException("node " + nodeRef +
" does not have aspect " + WCMAppModel.ASPECT_FORM_INSTANCE_DATA); " does not have aspect " + WCMAppModel.ASPECT_FORM_INSTANCE_DATA);
} }
this.nodeRef = nodeRef; this.nodeRef = nodeRef;
this.formsService = formsService; this.formsService = formsService;
} }
/* package */ FormInstanceDataImpl(final int version, /* package */ FormInstanceDataImpl(final int version,
final String avmPath, final String avmPath,
final FormsService formsService) final FormsService formsService)
{ {
this(AVMNodeConverter.ToNodeRef(version, avmPath), formsService); this(AVMNodeConverter.ToNodeRef(version, avmPath), formsService);
} }
private FormsService getFormsService() private FormsService getFormsService()
{ {
if (formsService == null) if (formsService == null)
{ {
formsService = (FormsService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "FormsService"); formsService = (FormsService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "FormsService");
} }
return formsService; return formsService;
} }
/** the name of this rendition */ /** the name of this rendition */
public String getName() public String getName()
{ {
// final AVMService avmService = this.getServiceRegistry().getAVMService(); // final AVMService avmService = this.getServiceRegistry().getAVMService();
// return avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(), // return avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(),
// AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(), // AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(),
// ContentModel.PROP_NAME).getStringValue(); // ContentModel.PROP_NAME).getStringValue();
return AVMNodeConverter.SplitBase(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond())[1]; return AVMNodeConverter.SplitBase(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond())[1];
} }
public String getWebappRelativePath() public String getWebappRelativePath()
{ {
return AVMUtil.getWebappRelativePath(this.getPath()); return AVMUtil.getWebappRelativePath(this.getPath());
} }
public String getSandboxRelativePath() public String getSandboxRelativePath()
{ {
return AVMUtil.getSandboxRelativePath(this.getPath()); return AVMUtil.getSandboxRelativePath(this.getPath());
} }
public String getPath() public String getPath()
{ {
return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(); return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond();
} }
public Document getDocument() public Document getDocument()
throws IOException, SAXException throws IOException, SAXException
{ {
return XMLUtil.parse(AVMNodeConverter.ToAVMVersionPath(nodeRef).getFirst(), return XMLUtil.parse(AVMNodeConverter.ToAVMVersionPath(nodeRef).getFirst(),
AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(), AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(),
this.getServiceRegistry().getAVMService()); this.getServiceRegistry().getAVMService());
} }
public Form getForm() public Form getForm()
throws FormNotFoundException throws FormNotFoundException
{ {
final String parentFormName = this.getParentFormName(); final String parentFormName = this.getParentFormName();
try try
{ {
// TODO - forms should be identified by nodeRef rather than name (which can be non-unique) // TODO - forms should be identified by nodeRef rather than name (which can be non-unique)
if (getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) if (getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
{ {
return this.getFormsService().getWebForm(parentFormName); return this.getFormsService().getWebForm(parentFormName);
} }
else else
{ {
return this.getFormsService().getForm(parentFormName); return this.getFormsService().getForm(parentFormName);
} }
} }
catch (FormNotFoundException fnfe) catch (FormNotFoundException fnfe)
{ {
throw new FormNotFoundException(parentFormName, this); throw new FormNotFoundException(parentFormName, this);
} }
} }
/** the node ref containing the contents of this rendition */ /** the node ref containing the contents of this rendition */
public NodeRef getNodeRef() public NodeRef getNodeRef()
{ {
return this.nodeRef; return this.nodeRef;
} }
public String getUrl() public String getUrl()
{ {
return AVMUtil.getPreviewURI(this.getPath()); return AVMUtil.getPreviewURI(this.getPath());
} }
public List<FormInstanceData.RegenerateResult> regenerateRenditions() public List<FormInstanceData.RegenerateResult> regenerateRenditions()
throws FormNotFoundException throws FormNotFoundException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("regenerating renditions of " + this); {
logger.debug("regenerating renditions of " + this);
AVMLockingService avmLockService = this.getServiceRegistry().getAVMLockingService(); }
final AVMService avmService = this.getServiceRegistry().getAVMService();
PropertyValue pv = avmService.getNodeProperty( AVMLockingService avmLockService = this.getServiceRegistry().getAVMLockingService();
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(), final AVMService avmService = this.getServiceRegistry().getAVMService();
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(), PropertyValue pv = avmService.getNodeProperty(
WCMAppModel.PROP_ORIGINAL_PARENT_PATH); AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(),
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(),
String originalParentAvmPath = (pv == null) ? WCMAppModel.PROP_ORIGINAL_PARENT_PATH);
AVMNodeConverter.SplitBase(this.getPath())[0] : pv.getStringValue();
String originalParentAvmPath = (pv == null) ?
final HashSet<RenderingEngineTemplate> allRets = AVMNodeConverter.SplitBase(this.getPath())[0] : pv.getStringValue();
new HashSet<RenderingEngineTemplate>(this.getForm().getRenderingEngineTemplates());
final List<RegenerateResult> result = new LinkedList<RegenerateResult>(); final HashSet<RenderingEngineTemplate> allRets =
// regenerate existing renditions new HashSet<RenderingEngineTemplate>(this.getForm().getRenderingEngineTemplates());
boolean renditionLockedBefore = false; final List<RegenerateResult> result = new LinkedList<RegenerateResult>();
String path = null; // regenerate existing renditions
boolean renditionLockedBefore = false;
for (final Rendition r : this.getRenditions()) String path = null;
{
// Try to skip renditions without rendering engine template. for (final Rendition r : this.getRenditions())
if (r instanceof RenditionImpl) {
{ // Try to skip renditions without rendering engine template.
RenditionImpl rImpl = (RenditionImpl)r; if (r instanceof RenditionImpl)
RenderingEngineTemplate ret = rImpl.getRenderingEngineTemplate(); {
if ((ret != null) && (ret instanceof RenderingEngineTemplateImpl)) RenditionImpl rImpl = (RenditionImpl)r;
{ RenderingEngineTemplate ret = rImpl.getRenderingEngineTemplate();
RenderingEngineTemplateImpl retImpl = (RenderingEngineTemplateImpl) ret; if ((ret != null) && (ret instanceof RenderingEngineTemplateImpl))
if (!retImpl.isExists()) {
{ RenderingEngineTemplateImpl retImpl = (RenderingEngineTemplateImpl) ret;
continue; if (!retImpl.isExists())
} {
} continue;
}
} }
final RenderingEngineTemplate ret = r.getRenderingEngineTemplate();
if (ret == null || !allRets.contains(ret)) }
{ final RenderingEngineTemplate ret = r.getRenderingEngineTemplate();
continue; if (ret == null || !allRets.contains(ret))
} {
try continue;
{ }
if (logger.isDebugEnabled()) try
logger.debug("regenerating rendition " + r + " using template " + ret); {
if (logger.isDebugEnabled())
renditionLockedBefore = false; {
path = r.getPath(); logger.debug("regenerating rendition " + r + " using template " + ret);
AVMLock lock = avmLockService.getLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path)); }
if (lock != null)
{ renditionLockedBefore = false;
renditionLockedBefore = true; path = r.getPath();
AVMLock lock = avmLockService.getLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
if (logger.isDebugEnabled()) if (lock != null)
logger.debug("Lock already exists for " + path); {
} renditionLockedBefore = true;
ret.render(this, r); if (logger.isDebugEnabled())
allRets.remove(ret); {
result.add(new RegenerateResult(ret, path, r)); logger.debug("Lock already exists for " + path);
} }
catch (Exception e) }
{
result.add(new RegenerateResult(ret, path, e)); ret.render(this, r);
allRets.remove(ret);
// remove lock if there wasn't one before result.add(new RegenerateResult(ret, path, r));
if (renditionLockedBefore == false) }
{ catch (Exception e)
avmLockService.removeLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path)); {
result.add(new RegenerateResult(ret, path, e));
if (logger.isDebugEnabled())
logger.debug("Removed lock for " + path + " as it failed to generate"); // remove lock if there wasn't one before
} if (renditionLockedBefore == false)
} {
} avmLockService.removeLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
// render all renditions for newly added templates if (logger.isDebugEnabled())
for (final RenderingEngineTemplate ret : allRets) {
{ logger.debug("Removed lock for " + path + " as it failed to generate");
try }
{ }
renditionLockedBefore = false; }
path = ret.getOutputPathForRendition(this, originalParentAvmPath, getName()); }
if (logger.isDebugEnabled()) // render all renditions for newly added templates
logger.debug("regenerating rendition of " + this.getPath() + for (final RenderingEngineTemplate ret : allRets)
" at " + path + " using template " + ret); {
try
AVMLock lock = avmLockService.getLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path)); {
if (lock != null) renditionLockedBefore = false;
{ path = ret.getOutputPathForRendition(this, originalParentAvmPath, getName());
renditionLockedBefore = true;
if (logger.isDebugEnabled())
if (logger.isDebugEnabled()) {
logger.debug("Lock already exists for " + path); logger.debug("regenerating rendition of " + this.getPath() +
} " at " + path + " using template " + ret);
}
result.add(new RegenerateResult(ret, path, ret.render(this, path)));
} AVMLock lock = avmLockService.getLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
catch (Exception e) if (lock != null)
{ {
result.add(new RegenerateResult(ret, path, e)); renditionLockedBefore = true;
// remove lock if there wasn't one before if (logger.isDebugEnabled())
if (renditionLockedBefore == false) {
{ logger.debug("Lock already exists for " + path);
avmLockService.removeLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path)); }
}
if (logger.isDebugEnabled())
logger.debug("Removed lock for " + path + " as it failed to generate"); result.add(new RegenerateResult(ret, path, ret.render(this, path)));
} }
} catch (Exception e)
} {
return result; result.add(new RegenerateResult(ret, path, e));
}
// remove lock if there wasn't one before
public List<Rendition> getRenditions() if (renditionLockedBefore == false)
{ {
final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService(); avmLockService.removeLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
final PropertyValue pv =
avmService.getNodeProperty(-1, this.getPath(), WCMAppModel.PROP_RENDITIONS); if (logger.isDebugEnabled())
final Collection<Serializable> renditionPaths = (pv == null {
? Collections.EMPTY_LIST logger.debug("Removed lock for " + path + " as it failed to generate");
: pv.getCollection(DataTypeDefinition.TEXT)); }
final String storeName = AVMUtil.getStoreName(this.getPath()); }
final List<Rendition> result = new ArrayList<Rendition>(renditionPaths.size()); }
for (Serializable path : renditionPaths) }
{ return result;
if (avmService.lookup(-1, storeName + ':' + (String)path) == null) }
{
if (logger.isDebugEnabled()) public List<Rendition> getRenditions()
logger.debug("ignoring dangling rendition at " + storeName + ':' + (String)path); {
} return getRenditions(false);
else }
{
final Rendition r = new RenditionImpl(-1, public List<Rendition> getRenditions(boolean includeDeleted)
storeName + ':' + (String)path, {
this.getFormsService()); final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService();
try final PropertyValue pv =
{ avmService.getNodeProperty(-1, this.getPath(), WCMAppModel.PROP_RENDITIONS);
if (!this.equals(r.getPrimaryFormInstanceData())) final Collection<Serializable> renditionPaths = (pv == null
{ ? Collections.EMPTY_LIST
if (logger.isDebugEnabled()) : pv.getCollection(DataTypeDefinition.TEXT));
logger.debug("rendition " + r + final String storeName = AVMUtil.getStoreName(this.getPath());
" points at form instance data " + r.getPrimaryFormInstanceData() + final List<Rendition> result = new ArrayList<Rendition>(renditionPaths.size());
" instead of " + this + ". Not including in renditions list."); for (Serializable path : renditionPaths)
continue; {
} String avmRenditionPath = AVMUtil.buildAVMPath(storeName, (String)path);
} if (avmService.lookup(-1, avmRenditionPath, includeDeleted) == null)
catch (FileNotFoundException fnfe) {
{ if (logger.isDebugEnabled())
continue; {
} logger.debug("ignoring dangling rendition at: " + avmRenditionPath);
if (r.getRenderingEngineTemplate() != null) }
{ }
result.add(r); else
} {
} final Rendition r = new RenditionImpl(-1,
} avmRenditionPath,
return result; this.getFormsService());
} try
{
private ServiceRegistry getServiceRegistry() if (!this.equals(r.getPrimaryFormInstanceData(includeDeleted)))
{ {
final FacesContext fc = FacesContext.getCurrentInstance(); if (logger.isDebugEnabled())
return Repository.getServiceRegistry(fc); {
} logger.debug("rendition " + r +
" points at form instance data " + r.getPrimaryFormInstanceData(includeDeleted) +
public int hashCode() " instead of " + this + ". Not including in renditions list.");
{ }
return this.getPath().hashCode(); continue;
} }
}
public String toString() catch (FileNotFoundException fnfe)
{ {
try continue;
{ }
return (this.getClass().getName() + "{path : " + this.getPath() + if (r.getRenderingEngineTemplate() != null)
", form : " + this.getForm().getName() + "}"); {
} result.add(r);
catch (FormNotFoundException fnfe) }
{ }
return (this.getClass().getName() + "{path : " + this.getPath() + }
", form : " + this.getParentFormName() + " NOT_FOUND! }"); return result;
}
}
} private ServiceRegistry getServiceRegistry()
{
public boolean equals(final Object other) final FacesContext fc = FacesContext.getCurrentInstance();
{ return Repository.getServiceRegistry(fc);
return (other instanceof FormInstanceDataImpl && }
this.getNodeRef().equals(((FormInstanceDataImpl)other).getNodeRef()));
public int hashCode()
} {
return this.getPath().hashCode();
protected String getParentFormName() }
{
final AVMService avmService = this.getServiceRegistry().getAVMService(); public String toString()
return avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(), {
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(), try
WCMAppModel.PROP_PARENT_FORM_NAME).getStringValue(); {
} return (this.getClass().getName() + "{path : " + this.getPath() +
} ", form : " + this.getForm().getName() + "}");
}
catch (FormNotFoundException fnfe)
{
return (this.getClass().getName() + "{path : " + this.getPath() +
", form : " + this.getParentFormName() + " NOT_FOUND! }");
}
}
public boolean equals(final Object other)
{
return (other instanceof FormInstanceDataImpl &&
this.getNodeRef().equals(((FormInstanceDataImpl)other).getNodeRef()));
}
protected String getParentFormName()
{
final AVMService avmService = this.getServiceRegistry().getAVMService();
return avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(),
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(),
WCMAppModel.PROP_PARENT_FORM_NAME).getStringValue();
}
}

View File

@@ -1,87 +1,91 @@
/* /*
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 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 * 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 * the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's * and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing * FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here: * the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" */ * http://www.alfresco.com/legal/licensing" */
package org.alfresco.web.forms; package org.alfresco.web.forms;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.Serializable; import java.io.Serializable;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
* Encapsulation of a rendition. * Encapsulation of a rendition.
* *
* @author Ariel Backenroth * @author Ariel Backenroth
*/ */
public interface Rendition public interface Rendition
extends Serializable extends Serializable
{ {
/** the name of this rendition */ /** the name of this rendition */
public String getName(); public String getName();
/** the description of this rendition */ /** the description of this rendition */
public String getDescription(); public String getDescription();
/** the path relative to the containing webapp */ /** the path relative to the containing webapp */
public String getWebappRelativePath(); public String getWebappRelativePath();
/** the path relative to the sandbox */ /** the path relative to the sandbox */
public String getSandboxRelativePath(); public String getSandboxRelativePath();
/** the primary form instance data used to generate this rendition */ /** the primary form instance data used to generate this rendition */
public FormInstanceData getPrimaryFormInstanceData() public FormInstanceData getPrimaryFormInstanceData()
throws FileNotFoundException; throws FileNotFoundException;
/** the rendering engine template that generated this rendition */ /** the primary form instance data used to generate this rendition (include deleted AVM nodes) */
public RenderingEngineTemplate getRenderingEngineTemplate(); public FormInstanceData getPrimaryFormInstanceData(boolean includeDeleted)
throws FileNotFoundException;
/** the path to the contents of this rendition */
public String getPath(); /** the rendering engine template that generated this rendition */
public RenderingEngineTemplate getRenderingEngineTemplate();
/** the url to the asset */
public String getUrl(); /** the path to the contents of this rendition */
public String getPath();
/** the file type image for the rendition */
public String getFileTypeImage(); /** the url to the asset */
public String getUrl();
/** the output stream for the rendition */
public OutputStream getOutputStream(); /** the file type image for the rendition */
public String getFileTypeImage();
/** the HTML label attribute for UI */
public String getLabelAttribute(); /** the output stream for the rendition */
public OutputStream getOutputStream();
/** the HTML description attribute for UI */
public String getDescriptionAttribute(); /** the HTML label attribute for UI */
public String getLabelAttribute();
/** regenerates the contents of this rendition using the primary form instance data */
public void regenerate() /** the HTML description attribute for UI */
throws IOException, public String getDescriptionAttribute();
RenderingEngine.RenderingException,
SAXException; /** regenerates the contents of this rendition using the primary form instance data */
public void regenerate()
/** regenerates the contents of this rendition using the provided form instance data*/ throws IOException,
public void regenerate(final FormInstanceData formInstanceData) RenderingEngine.RenderingException,
throws IOException, SAXException;
RenderingEngine.RenderingException,
SAXException; /** regenerates the contents of this rendition using the provided form instance data*/
} public void regenerate(final FormInstanceData formInstanceData)
throws IOException,
RenderingEngine.RenderingException,
SAXException;
}

View File

@@ -135,6 +135,12 @@ import org.xml.sax.SAXException;
} }
public FormInstanceData getPrimaryFormInstanceData() public FormInstanceData getPrimaryFormInstanceData()
throws FileNotFoundException
{
return getPrimaryFormInstanceData(false);
}
public FormInstanceData getPrimaryFormInstanceData(boolean includeDeleted)
throws FileNotFoundException throws FileNotFoundException
{ {
final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService(); final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService();
@@ -145,7 +151,7 @@ import org.xml.sax.SAXException;
String avmStore = AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(); String avmStore = AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond();
avmStore = avmStore.substring(0, avmStore.indexOf(':')); avmStore = avmStore.substring(0, avmStore.indexOf(':'));
final String path = avmStore + ':' + fidAVMStoreRelativePath; final String path = avmStore + ':' + fidAVMStoreRelativePath;
if (avmService.lookup(-1, path) == null) if (avmService.lookup(-1, path, includeDeleted) == null)
{ {
throw new FileNotFoundException("unable to find primary form instance data " + path); throw new FileNotFoundException("unable to find primary form instance data " + path);
} }