mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V4.0-BUG-FIX to HEAD
35224: ALF-12038: Remove trailing JSON comma causing IE7 script error 35226: ALF-13401 - Saving PowerPoint (mac 2011) via CIFS fails in Mac OS X Lion 35239: ALF-13409: Further fix to deal with concurrent deletion of a user's site invitations in background 35245: ALF-13281: Enabled use of autocomplete in IE for forms runtime. This change also allows multiple events to be attached per validation handler 35253: ALF-13640: Fixed issues with updating task associations + added new test + fixed existing activiti-component-tests 35271: Translation updates (fixes: ALF-13434) - based on EN r35212. (Dutch still to follow) 35281: ALF-13227: Fix CSS for Wiki layout of nested lists 35284: SPANISH: Update from Gloria 35290: More debug + unit test for mac powerpoint shuffle. 35291: Added isTemporary method 35295: ALF-13453 : Remote Code Execution (can create reverse shell). - Added ability for XMLUtil parse callers to provide an optional array of XMLFilterImpl to be used while parsing. -Added secureParseXSL methods that automatically install an XMLFilterImpl that causes a parse failure if any insecure namespaces are encountered. 35303: Fix for ALF-12444 Node Browser improvement: Index single node and remove single node from indexes Part of ALF-13723 SOLR does not include the same query unit tests as lucene 35305: ALF-13723 SOLR does not include the same query unit tests as lucene - test template 35306: ALF-13723 SOLR does not include the same query unit tests as lucene - template for creating test cores 35323: ALF-13420: Natural sort on form option labels and improvement for CSS - specifically to address transform action in document details. 35328: ALF-13409: Avoid concurrency issues in unit test tear downs by deleting users before sites. User deletion deletes invitations synchronously. Site deletion deletes invitations concurrently to avoid UI timeouts. The potential to access invitations that are being concurrently deleted still exists, but always did! 35331: ALF-12126: Ensure that DND upload is disabled for users with only consumer access 35335: ALF-13708: Merged V3.4-BUG-FIX (3.4.10) to V4.0-BUG-FIX (4.0.2) 35235: ALF-13673: Amp-loaded duplicated mimetypes should be handled - Modified code to allow duplicates to replace parts of the existing mimetype definitions. - A warning is logged each time. 35336: Spanish and Dutch updates from Gloria, based on EN r35212 35355: Merged V3.4-BUG-FIX to V4.0-BUG-FIX 35213: ALF-13686: Merged PATCHES/V3.4.8 to V3.4-BUG-FIX 34943: ALF-13121: Option to create users either as user1 or user1@domain.com after kerberos authentication - New Kerberos subsystem parameter kerberos.authentication.stripUsernameSuffix introduced - When true (the default) the @domain sufix will be stripped from Kerberos authenticated usernames in CIFS, SPP, WebDAV and the Web Client - When false, should enable a multi-domain customer to use Alfresco (says Mr Gninot) 35096: ALF-13121: Added missing stripKerberosUsernameSuffix property to sharepointAuthenticationHandler 35215: ALF-13065: Ensure Wiki new page save button is available on HTML edit action 35219: ALF-11898: Fixed TinyMCE create HTML content problem for Explorer client 35261: Translation updates based on EN r35144 35339: AD 2008 R2, user import via LDAP fails with over 1000 users - Problem discovered by Community user with simple workaround https://forums.alfresco.com/en/viewtopic.php?f=57&t=43960&sid=5569e5cfbccb3776e11ef4a8e9d50378&p=129664#p129664 35353: Merged V3.4 to V3.4-BUG-FIX 35279: ALF-13713: Merged PATCHES/V3.4.8 to V3.4 35146: Merged DEV to PATCHES/V3.4.8 35130: ALF-13472: Webdav Does not allow a user to access spaces without read permission on parent spaces Receiving of indirect lock is wrapped into AuthenticationUtil.runAs() invocation to provide a possibility of getting indirect lock for users with appropriate access rights for requested resource 35280: ALF-10353: Internet Explorer hangs when using the object picker with a larger number of documents - reviewed by DD 35318: ALF-13715: Merged HEAD to V3.4 31743: Fixed ALF-10157: Web Form Details page for the "Selected Web Content Forms": script error appears on help button click: container.jsp (line 382) 35341: ALF-13552: Merged V4.0 to V3.4 35296: ALF-13453: Remote Code Execution (can create reverse shell) - Fix by Shane 35304: ALF-13453: Extra fix to ensure xalan namespace isn't declared with global scope and can't be hijacked by an input stylesheet 35307: ALF-13453: Duplicated extra fix to duplicate code in XSLTRenderingEngine! 35354: Merged V3.4 to V3.4-BUG-FIX (RECORD ONLY) 35266: Merged V3.4-BUG-FIX to V3.4 35261: Translation updates based on EN r35144 35334: Merged V3.4-BUG-FIX to V3.4 35235: ALF-13673: Amp-loaded duplicated mimetypes should be handled - Modified code to allow duplicates to replace parts of the existing mimetype definitions. - A warning is logged each time. 35356: Merged V4.0 to V4.0-BUG-FIX 35292: ALF-13721: Merged PATCHES/V4.0.0 to V4.0 35240: Fix for ALF-13685 The SOLr textContent webscript is not protected by authentication and permission checks. 35242: Fix for ALF-13685 The SOLr textContent webscript is not protected by authentication and permission checks. - /wcs/api/solr and /wcservice/api/solr 35304: ALF-13453: Extra fix to ensure xalan namespace isn't declared with global scope and can't be hijacked by an input stylesheet 35307: ALF-13453: Duplicated extra fix to duplicate code in XSLTRenderingEngine! 35357: Merged V4.0 to V4.0-BUG-FIX (RECORD ONLY) 35048: Merged V4.0-BUG-FIX to V4.0 35031: Fix for ALF-12309: Script errors on site pages 35293: Merged V4.0-BUG-FIX to V4.0 35172: ALF-13626: category.put.json.ftl has wrong bracket 35296: Merged V4.0-BUG-FIX to V4.0 35295: ALF-13453: Remote Code Execution (can create reverse shell) - Fix by Shane git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@35359 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -35,7 +35,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.alfresco.web.app.servlet.ajax.InvokeCommand;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
|
@@ -48,7 +48,7 @@ import org.springframework.extensions.surf.util.URLDecoder;
|
||||
import org.alfresco.web.app.servlet.BaseServlet;
|
||||
import org.alfresco.web.app.servlet.ajax.InvokeCommand;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
|
@@ -50,7 +50,7 @@ import org.alfresco.web.forms.Form;
|
||||
import org.alfresco.web.forms.FormNotFoundException;
|
||||
import org.alfresco.web.forms.FormProcessor;
|
||||
import org.alfresco.web.forms.FormsService;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@@ -64,7 +64,7 @@ import org.alfresco.web.forms.FormsService;
|
||||
import org.alfresco.web.forms.RenderingEngine;
|
||||
import org.alfresco.web.forms.RenderingEngineTemplate;
|
||||
import org.alfresco.web.forms.RenderingEngineTemplateImpl;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.component.UIListItem;
|
||||
import org.alfresco.web.ui.wcm.WebResources;
|
||||
|
@@ -65,7 +65,7 @@ import org.alfresco.web.forms.FormNotFoundException;
|
||||
import org.alfresco.web.forms.FormsService;
|
||||
import org.alfresco.web.forms.RenderingEngineTemplate;
|
||||
import org.alfresco.web.forms.Rendition;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.component.UIListItem;
|
||||
import org.alfresco.web.ui.wcm.component.UIUserSandboxes;
|
||||
|
@@ -32,7 +32,7 @@ import org.alfresco.web.forms.Form;
|
||||
import org.alfresco.web.forms.FormInstanceData;
|
||||
import org.alfresco.web.forms.FormNotFoundException;
|
||||
import org.alfresco.web.forms.Rendition;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@@ -64,7 +64,7 @@ import org.alfresco.web.app.servlet.ajax.InvokeCommand;
|
||||
import org.alfresco.web.bean.FileUploadBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
|
@@ -44,6 +44,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.util.XMLUtil;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
|
@@ -1,475 +1,476 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.web.forms;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
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.avm.locking.AVMLockingService;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.wcm.util.WCMUtil;
|
||||
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.bean.wcm.WebProject;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Encapsulation of a rendition.
|
||||
*
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
/* 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 WebProject webProject;
|
||||
private transient FormsService formsService;
|
||||
|
||||
/* package */ FormInstanceDataImpl(final NodeRef nodeRef,
|
||||
final FormsService formsService)
|
||||
{
|
||||
this(nodeRef, formsService, null);
|
||||
}
|
||||
|
||||
/* package */ FormInstanceDataImpl(final NodeRef nodeRef,
|
||||
final FormsService formsService,
|
||||
final WebProject webProject)
|
||||
{
|
||||
this.webProject = webProject;
|
||||
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (formsService == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
final AVMService avmService = this.getServiceRegistry().getAVMService();
|
||||
|
||||
Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
||||
|
||||
if (avmService.lookup(avmVersionPath.getFirst(), avmVersionPath.getSecond()) == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Not found: " + avmVersionPath.getSecond());
|
||||
}
|
||||
|
||||
if (!avmService.hasAspect(avmVersionPath.getFirst(), avmVersionPath.getSecond(),
|
||||
WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
|
||||
{
|
||||
throw new IllegalArgumentException("node " + nodeRef +
|
||||
" does not have aspect " + WCMAppModel.ASPECT_FORM_INSTANCE_DATA);
|
||||
}
|
||||
this.nodeRef = nodeRef;
|
||||
this.formsService = formsService;
|
||||
}
|
||||
|
||||
/* package */ FormInstanceDataImpl(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];
|
||||
}
|
||||
|
||||
public String getWebappRelativePath()
|
||||
{
|
||||
return AVMUtil.getWebappRelativePath(this.getPath());
|
||||
}
|
||||
|
||||
public String getSandboxRelativePath()
|
||||
{
|
||||
return AVMUtil.getSandboxRelativePath(this.getPath());
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond();
|
||||
}
|
||||
|
||||
public Document getDocument()
|
||||
throws IOException, SAXException
|
||||
{
|
||||
return XMLUtil.parse(AVMNodeConverter.ToAVMVersionPath(nodeRef).getFirst(),
|
||||
AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(),
|
||||
this.getServiceRegistry().getAVMService());
|
||||
}
|
||||
|
||||
public Form getForm()
|
||||
throws FormNotFoundException
|
||||
{
|
||||
final String parentFormName = this.getParentFormName();
|
||||
try
|
||||
{
|
||||
// TODO - forms should be identified by nodeRef rather than name (which can be non-unique)
|
||||
if (getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
|
||||
{
|
||||
if (webProject != null)
|
||||
{
|
||||
return webProject.getForm(parentFormName);
|
||||
}
|
||||
|
||||
return this.getFormsService().getWebForm(parentFormName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.getFormsService().getForm(parentFormName);
|
||||
}
|
||||
}
|
||||
catch (FormNotFoundException fnfe)
|
||||
{
|
||||
if (webProject != null)
|
||||
{
|
||||
throw new FormNotFoundException(parentFormName, webProject, this);
|
||||
}
|
||||
|
||||
throw new FormNotFoundException(parentFormName, this);
|
||||
}
|
||||
}
|
||||
|
||||
/** the node ref containing the contents of this rendition */
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.nodeRef;
|
||||
}
|
||||
|
||||
public String getUrl()
|
||||
{
|
||||
return AVMUtil.getPreviewURI(this.getPath());
|
||||
}
|
||||
|
||||
public List<FormInstanceData.RegenerateResult> regenerateRenditions()
|
||||
throws FormNotFoundException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("regenerating renditions of " + this);
|
||||
}
|
||||
|
||||
AVMLockingService avmLockService = this.getServiceRegistry().getAVMLockingService();
|
||||
final AVMService avmService = this.getServiceRegistry().getAVMService();
|
||||
PropertyValue pv = avmService.getNodeProperty(
|
||||
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(),
|
||||
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(),
|
||||
WCMAppModel.PROP_ORIGINAL_PARENT_PATH);
|
||||
|
||||
String originalParentAvmPath = (pv == null) ?
|
||||
AVMNodeConverter.SplitBase(this.getPath())[0] : pv.getStringValue();
|
||||
|
||||
final HashSet<RenderingEngineTemplate> allRets =
|
||||
new HashSet<RenderingEngineTemplate>(this.getForm().getRenderingEngineTemplates());
|
||||
final List<RegenerateResult> result = new LinkedList<RegenerateResult>();
|
||||
// regenerate existing renditions
|
||||
String path = null;
|
||||
|
||||
for (final Rendition r : this.getRenditions())
|
||||
{
|
||||
// Try to skip renditions without rendering engine template.
|
||||
if (r instanceof RenditionImpl)
|
||||
{
|
||||
RenditionImpl rImpl = (RenditionImpl)r;
|
||||
RenderingEngineTemplate ret = rImpl.getRenderingEngineTemplate();
|
||||
if ((ret != null) && (ret instanceof RenderingEngineTemplateImpl))
|
||||
{
|
||||
RenderingEngineTemplateImpl retImpl = (RenderingEngineTemplateImpl) ret;
|
||||
if (!retImpl.isExists())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
final RenderingEngineTemplate ret = r.getRenderingEngineTemplate();
|
||||
if (ret == null || !allRets.contains(ret))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String lockOwner = null;
|
||||
try
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("regenerating rendition " + r + " using template " + ret);
|
||||
}
|
||||
|
||||
path = r.getPath();
|
||||
lockOwner = avmLockService.getLockOwner(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
|
||||
if (lockOwner != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Lock already exists for " + path);
|
||||
}
|
||||
}
|
||||
|
||||
ret.render(this, r);
|
||||
allRets.remove(ret);
|
||||
result.add(new RegenerateResult(ret, path, r, lockOwner));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.add(new RegenerateResult(ret, path, e, lockOwner));
|
||||
|
||||
// remove lock if there wasn't one before
|
||||
if (lockOwner == null)
|
||||
{
|
||||
avmLockService.removeLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Removed lock for " + path + " as it failed to generate");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get current username for lock checks
|
||||
String username = Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName();
|
||||
|
||||
// render all renditions for newly added templates
|
||||
for (final RenderingEngineTemplate ret : allRets)
|
||||
{
|
||||
String lockOwner = null;
|
||||
String currentLockStore = null;
|
||||
boolean lockModified = false;
|
||||
|
||||
try
|
||||
{
|
||||
path = ret.getOutputPathForRendition(this, originalParentAvmPath, getName().replaceAll("(.+)\\..*", "$1"));
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("regenerating rendition of " + this.getPath() +
|
||||
" at " + path + " using template " + ret);
|
||||
}
|
||||
|
||||
String storeId = AVMUtil.getStoreId(path);
|
||||
String storePath = AVMUtil.getStoreRelativePath(path);
|
||||
String storeName = AVMUtil.getStoreName(path);
|
||||
|
||||
Map<String, String> lockData = avmLockService.getLockData(storeId, storePath);
|
||||
if (lockData != null)
|
||||
{
|
||||
lockOwner = avmLockService.getLockOwner(storeId, storePath);
|
||||
currentLockStore = lockData.get(WCMUtil.LOCK_KEY_STORE_NAME);
|
||||
}
|
||||
|
||||
if (lockOwner != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Lock already exists for " + path);
|
||||
}
|
||||
|
||||
if (currentLockStore.equals(storeName) == false)
|
||||
{
|
||||
if (lockOwner.equals(username))
|
||||
{
|
||||
lockModified = true;
|
||||
|
||||
// lock already exists on path, check it's owned by the current user
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("transferring lock from " + currentLockStore + " to " + storeName + " for path: " + path);
|
||||
}
|
||||
|
||||
lockData.put(WCMUtil.LOCK_KEY_STORE_NAME, storeName);
|
||||
avmLockService.modifyLock(storeId, storePath, lockOwner, storeId, storePath, lockData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.add(new RegenerateResult(ret, path, ret.render(this, path), lockOwner));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.add(new RegenerateResult(ret, path, e, lockOwner));
|
||||
|
||||
String storeId = AVMUtil.getStoreId(path);
|
||||
String storePath = AVMUtil.getStoreRelativePath(path);
|
||||
String storeName = AVMUtil.getStoreName(path);
|
||||
|
||||
if (lockOwner == null)
|
||||
{
|
||||
// remove lock if there wasn't one before
|
||||
avmLockService.removeLock(storeId, storePath);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Removed lock for " + path + " as it failed to generate");
|
||||
}
|
||||
}
|
||||
else if (lockModified)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("transferring lock from " + storeName + " to " + currentLockStore + " for path: " + path);
|
||||
}
|
||||
|
||||
Map<String, String> lockData = avmLockService.getLockData(storeId, storePath);
|
||||
lockData.put(WCMUtil.LOCK_KEY_STORE_NAME, currentLockStore);
|
||||
avmLockService.modifyLock(storeId, storePath, lockOwner, storeId, storePath, lockData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Rendition> getRenditions()
|
||||
{
|
||||
return getRenditions(false);
|
||||
}
|
||||
|
||||
public List<Rendition> getRenditions(boolean includeDeleted)
|
||||
{
|
||||
final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService();
|
||||
final PropertyValue pv =
|
||||
avmService.getNodeProperty(-1, this.getPath(), WCMAppModel.PROP_RENDITIONS);
|
||||
final Collection<Serializable> renditionPaths = (pv == null
|
||||
? Collections.EMPTY_LIST
|
||||
: pv.getCollection(DataTypeDefinition.TEXT));
|
||||
final String storeName = AVMUtil.getStoreName(this.getPath());
|
||||
final List<Rendition> result = new ArrayList<Rendition>(renditionPaths.size());
|
||||
for (Serializable path : renditionPaths)
|
||||
{
|
||||
String avmRenditionPath = AVMUtil.buildAVMPath(storeName, (String)path);
|
||||
if (avmService.lookup(-1, avmRenditionPath, includeDeleted) == null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("ignoring dangling rendition at: " + avmRenditionPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final Rendition r = new RenditionImpl(-1,
|
||||
avmRenditionPath,
|
||||
this.getFormsService());
|
||||
try
|
||||
{
|
||||
if (!this.equals(r.getPrimaryFormInstanceData(includeDeleted)))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("rendition " + r +
|
||||
" points at form instance data " + r.getPrimaryFormInstanceData(includeDeleted) +
|
||||
" instead of " + this + ". Not including in renditions list.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException fnfe)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (r.getRenderingEngineTemplate() != null)
|
||||
{
|
||||
result.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||
return Repository.getServiceRegistry(fc);
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return this.getPath().hashCode();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.web.forms;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
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.avm.locking.AVMLockingService;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.alfresco.wcm.util.WCMUtil;
|
||||
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.bean.wcm.WebProject;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Encapsulation of a rendition.
|
||||
*
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
/* 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 WebProject webProject;
|
||||
private transient FormsService formsService;
|
||||
|
||||
/* package */ FormInstanceDataImpl(final NodeRef nodeRef,
|
||||
final FormsService formsService)
|
||||
{
|
||||
this(nodeRef, formsService, null);
|
||||
}
|
||||
|
||||
/* package */ FormInstanceDataImpl(final NodeRef nodeRef,
|
||||
final FormsService formsService,
|
||||
final WebProject webProject)
|
||||
{
|
||||
this.webProject = webProject;
|
||||
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (formsService == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
final AVMService avmService = this.getServiceRegistry().getAVMService();
|
||||
|
||||
Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
||||
|
||||
if (avmService.lookup(avmVersionPath.getFirst(), avmVersionPath.getSecond()) == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Not found: " + avmVersionPath.getSecond());
|
||||
}
|
||||
|
||||
if (!avmService.hasAspect(avmVersionPath.getFirst(), avmVersionPath.getSecond(),
|
||||
WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
|
||||
{
|
||||
throw new IllegalArgumentException("node " + nodeRef +
|
||||
" does not have aspect " + WCMAppModel.ASPECT_FORM_INSTANCE_DATA);
|
||||
}
|
||||
this.nodeRef = nodeRef;
|
||||
this.formsService = formsService;
|
||||
}
|
||||
|
||||
/* package */ FormInstanceDataImpl(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];
|
||||
}
|
||||
|
||||
public String getWebappRelativePath()
|
||||
{
|
||||
return AVMUtil.getWebappRelativePath(this.getPath());
|
||||
}
|
||||
|
||||
public String getSandboxRelativePath()
|
||||
{
|
||||
return AVMUtil.getSandboxRelativePath(this.getPath());
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond();
|
||||
}
|
||||
|
||||
public Document getDocument()
|
||||
throws IOException, SAXException
|
||||
{
|
||||
return XMLUtil.parse(AVMNodeConverter.ToAVMVersionPath(nodeRef).getFirst(),
|
||||
AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(),
|
||||
this.getServiceRegistry().getAVMService());
|
||||
}
|
||||
|
||||
public Form getForm()
|
||||
throws FormNotFoundException
|
||||
{
|
||||
final String parentFormName = this.getParentFormName();
|
||||
try
|
||||
{
|
||||
// TODO - forms should be identified by nodeRef rather than name (which can be non-unique)
|
||||
if (getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
|
||||
{
|
||||
if (webProject != null)
|
||||
{
|
||||
return webProject.getForm(parentFormName);
|
||||
}
|
||||
|
||||
return this.getFormsService().getWebForm(parentFormName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.getFormsService().getForm(parentFormName);
|
||||
}
|
||||
}
|
||||
catch (FormNotFoundException fnfe)
|
||||
{
|
||||
if (webProject != null)
|
||||
{
|
||||
throw new FormNotFoundException(parentFormName, webProject, this);
|
||||
}
|
||||
|
||||
throw new FormNotFoundException(parentFormName, this);
|
||||
}
|
||||
}
|
||||
|
||||
/** the node ref containing the contents of this rendition */
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.nodeRef;
|
||||
}
|
||||
|
||||
public String getUrl()
|
||||
{
|
||||
return AVMUtil.getPreviewURI(this.getPath());
|
||||
}
|
||||
|
||||
public List<FormInstanceData.RegenerateResult> regenerateRenditions()
|
||||
throws FormNotFoundException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("regenerating renditions of " + this);
|
||||
}
|
||||
|
||||
AVMLockingService avmLockService = this.getServiceRegistry().getAVMLockingService();
|
||||
final AVMService avmService = this.getServiceRegistry().getAVMService();
|
||||
PropertyValue pv = avmService.getNodeProperty(
|
||||
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(),
|
||||
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(),
|
||||
WCMAppModel.PROP_ORIGINAL_PARENT_PATH);
|
||||
|
||||
String originalParentAvmPath = (pv == null) ?
|
||||
AVMNodeConverter.SplitBase(this.getPath())[0] : pv.getStringValue();
|
||||
|
||||
final HashSet<RenderingEngineTemplate> allRets =
|
||||
new HashSet<RenderingEngineTemplate>(this.getForm().getRenderingEngineTemplates());
|
||||
final List<RegenerateResult> result = new LinkedList<RegenerateResult>();
|
||||
// regenerate existing renditions
|
||||
String path = null;
|
||||
|
||||
for (final Rendition r : this.getRenditions())
|
||||
{
|
||||
// Try to skip renditions without rendering engine template.
|
||||
if (r instanceof RenditionImpl)
|
||||
{
|
||||
RenditionImpl rImpl = (RenditionImpl)r;
|
||||
RenderingEngineTemplate ret = rImpl.getRenderingEngineTemplate();
|
||||
if ((ret != null) && (ret instanceof RenderingEngineTemplateImpl))
|
||||
{
|
||||
RenderingEngineTemplateImpl retImpl = (RenderingEngineTemplateImpl) ret;
|
||||
if (!retImpl.isExists())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
final RenderingEngineTemplate ret = r.getRenderingEngineTemplate();
|
||||
if (ret == null || !allRets.contains(ret))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String lockOwner = null;
|
||||
try
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("regenerating rendition " + r + " using template " + ret);
|
||||
}
|
||||
|
||||
path = r.getPath();
|
||||
lockOwner = avmLockService.getLockOwner(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
|
||||
if (lockOwner != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Lock already exists for " + path);
|
||||
}
|
||||
}
|
||||
|
||||
ret.render(this, r);
|
||||
allRets.remove(ret);
|
||||
result.add(new RegenerateResult(ret, path, r, lockOwner));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.add(new RegenerateResult(ret, path, e, lockOwner));
|
||||
|
||||
// remove lock if there wasn't one before
|
||||
if (lockOwner == null)
|
||||
{
|
||||
avmLockService.removeLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Removed lock for " + path + " as it failed to generate");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get current username for lock checks
|
||||
String username = Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName();
|
||||
|
||||
// render all renditions for newly added templates
|
||||
for (final RenderingEngineTemplate ret : allRets)
|
||||
{
|
||||
String lockOwner = null;
|
||||
String currentLockStore = null;
|
||||
boolean lockModified = false;
|
||||
|
||||
try
|
||||
{
|
||||
path = ret.getOutputPathForRendition(this, originalParentAvmPath, getName().replaceAll("(.+)\\..*", "$1"));
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("regenerating rendition of " + this.getPath() +
|
||||
" at " + path + " using template " + ret);
|
||||
}
|
||||
|
||||
String storeId = AVMUtil.getStoreId(path);
|
||||
String storePath = AVMUtil.getStoreRelativePath(path);
|
||||
String storeName = AVMUtil.getStoreName(path);
|
||||
|
||||
Map<String, String> lockData = avmLockService.getLockData(storeId, storePath);
|
||||
if (lockData != null)
|
||||
{
|
||||
lockOwner = avmLockService.getLockOwner(storeId, storePath);
|
||||
currentLockStore = lockData.get(WCMUtil.LOCK_KEY_STORE_NAME);
|
||||
}
|
||||
|
||||
if (lockOwner != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Lock already exists for " + path);
|
||||
}
|
||||
|
||||
if (currentLockStore.equals(storeName) == false)
|
||||
{
|
||||
if (lockOwner.equals(username))
|
||||
{
|
||||
lockModified = true;
|
||||
|
||||
// lock already exists on path, check it's owned by the current user
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("transferring lock from " + currentLockStore + " to " + storeName + " for path: " + path);
|
||||
}
|
||||
|
||||
lockData.put(WCMUtil.LOCK_KEY_STORE_NAME, storeName);
|
||||
avmLockService.modifyLock(storeId, storePath, lockOwner, storeId, storePath, lockData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.add(new RegenerateResult(ret, path, ret.render(this, path), lockOwner));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.add(new RegenerateResult(ret, path, e, lockOwner));
|
||||
|
||||
String storeId = AVMUtil.getStoreId(path);
|
||||
String storePath = AVMUtil.getStoreRelativePath(path);
|
||||
String storeName = AVMUtil.getStoreName(path);
|
||||
|
||||
if (lockOwner == null)
|
||||
{
|
||||
// remove lock if there wasn't one before
|
||||
avmLockService.removeLock(storeId, storePath);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Removed lock for " + path + " as it failed to generate");
|
||||
}
|
||||
}
|
||||
else if (lockModified)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("transferring lock from " + storeName + " to " + currentLockStore + " for path: " + path);
|
||||
}
|
||||
|
||||
Map<String, String> lockData = avmLockService.getLockData(storeId, storePath);
|
||||
lockData.put(WCMUtil.LOCK_KEY_STORE_NAME, currentLockStore);
|
||||
avmLockService.modifyLock(storeId, storePath, lockOwner, storeId, storePath, lockData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Rendition> getRenditions()
|
||||
{
|
||||
return getRenditions(false);
|
||||
}
|
||||
|
||||
public List<Rendition> getRenditions(boolean includeDeleted)
|
||||
{
|
||||
final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService();
|
||||
final PropertyValue pv =
|
||||
avmService.getNodeProperty(-1, this.getPath(), WCMAppModel.PROP_RENDITIONS);
|
||||
final Collection<Serializable> renditionPaths = (pv == null
|
||||
? Collections.EMPTY_LIST
|
||||
: pv.getCollection(DataTypeDefinition.TEXT));
|
||||
final String storeName = AVMUtil.getStoreName(this.getPath());
|
||||
final List<Rendition> result = new ArrayList<Rendition>(renditionPaths.size());
|
||||
for (Serializable path : renditionPaths)
|
||||
{
|
||||
String avmRenditionPath = AVMUtil.buildAVMPath(storeName, (String)path);
|
||||
if (avmService.lookup(-1, avmRenditionPath, includeDeleted) == null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("ignoring dangling rendition at: " + avmRenditionPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final Rendition r = new RenditionImpl(-1,
|
||||
avmRenditionPath,
|
||||
this.getFormsService());
|
||||
try
|
||||
{
|
||||
if (!this.equals(r.getPrimaryFormInstanceData(includeDeleted)))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("rendition " + r +
|
||||
" points at form instance data " + r.getPrimaryFormInstanceData(includeDeleted) +
|
||||
" instead of " + this + ". Not including in renditions list.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException fnfe)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (r.getRenderingEngineTemplate() != null)
|
||||
{
|
||||
result.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||
return Repository.getServiceRegistry(fc);
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return this.getPath().hashCode();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.util.TestWithUserUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
|
@@ -58,6 +58,7 @@ import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.namespace.DynamicNamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.springframework.extensions.surf.util.URLDecoder;
|
||||
import org.springframework.extensions.surf.util.URLEncoder;
|
||||
import org.alfresco.web.app.Application;
|
||||
|
@@ -1,276 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package org.alfresco.web.forms;
|
||||
|
||||
import java.io.*;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* XML utility functions.
|
||||
*
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
public class XMLUtil
|
||||
{
|
||||
private static final Log LOGGER = LogFactory.getLog(XMLUtil.class);
|
||||
|
||||
/** utility function for creating a document */
|
||||
public static Document newDocument()
|
||||
{
|
||||
return XMLUtil.getDocumentBuilder().newDocument();
|
||||
}
|
||||
|
||||
/** utility function for serializing a node */
|
||||
public static void print(final Node n, final Writer output)
|
||||
{
|
||||
XMLUtil.print(n, output, true);
|
||||
}
|
||||
|
||||
/** utility function for serializing a node */
|
||||
public static void print(final Node n, final Writer output, final boolean indent)
|
||||
{
|
||||
try
|
||||
{
|
||||
final TransformerFactory tf = TransformerFactory.newInstance();
|
||||
final Transformer t = tf.newTransformer();
|
||||
t.setOutputProperty(OutputKeys.INDENT, indent ? "yes" : "no");
|
||||
t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
|
||||
t.setOutputProperty(OutputKeys.METHOD, "xml");
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("writing out a document for " +
|
||||
(n instanceof Document
|
||||
? ((Document)n).getDocumentElement()
|
||||
: n).getNodeName() +
|
||||
" to " + (output instanceof StringWriter
|
||||
? "string"
|
||||
: output));
|
||||
}
|
||||
t.transform(new DOMSource(n), new StreamResult(output));
|
||||
}
|
||||
catch (TransformerException te)
|
||||
{
|
||||
te.printStackTrace();
|
||||
assert false : te.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/** utility function for serializing a node */
|
||||
public static void print(final Node n, final File output)
|
||||
throws IOException
|
||||
{
|
||||
XMLUtil.print(n, new FileWriter(output));
|
||||
}
|
||||
|
||||
/** utility function for serializing a node */
|
||||
public static String toString(final Node n)
|
||||
{
|
||||
return XMLUtil.toString(n, true);
|
||||
}
|
||||
|
||||
/** utility function for serializing a node */
|
||||
public static String toString(final Node n, final boolean indent)
|
||||
{
|
||||
final StringWriter result = new StringWriter();
|
||||
XMLUtil.print(n, result, indent);
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/** utility function for parsing xml */
|
||||
public static Document parse(final String source)
|
||||
throws SAXException,
|
||||
IOException
|
||||
{
|
||||
return XMLUtil.parse(new ByteArrayInputStream(source.getBytes("UTF-8")));
|
||||
}
|
||||
|
||||
/** utility function for parsing xml */
|
||||
public static Document parse(final NodeRef nodeRef,
|
||||
final ContentService contentService)
|
||||
throws SAXException,
|
||||
IOException
|
||||
{
|
||||
final ContentReader contentReader =
|
||||
contentService.getReader(nodeRef, ContentModel.TYPE_CONTENT);
|
||||
final InputStream in = contentReader.getContentInputStream();
|
||||
return XMLUtil.parse(in);
|
||||
}
|
||||
|
||||
/** utility function for parsing xml */
|
||||
public static Document parse(final int version,
|
||||
final String path,
|
||||
final AVMService avmService)
|
||||
throws SAXException,
|
||||
IOException
|
||||
{
|
||||
return XMLUtil.parse(avmService.getFileInputStream(version, path));
|
||||
}
|
||||
|
||||
/** utility function for parsing xml */
|
||||
public static Document parse(final File source)
|
||||
throws SAXException,
|
||||
IOException
|
||||
{
|
||||
return XMLUtil.parse(new FileInputStream(source));
|
||||
}
|
||||
|
||||
/** utility function for parsing xml */
|
||||
public static Document parse(final InputStream source)
|
||||
throws SAXException,
|
||||
IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
final DocumentBuilder db = XMLUtil.getDocumentBuilder();
|
||||
return db.parse(source);
|
||||
}
|
||||
finally
|
||||
{
|
||||
source.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** provides a document builder that is namespace aware but not validating by default */
|
||||
public static DocumentBuilder getDocumentBuilder()
|
||||
{
|
||||
return XMLUtil.getDocumentBuilder(true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* FOR DIAGNOSTIC PURPOSES ONLY - incomplete<br/>
|
||||
* Builds a path to the node relative to the to node provided.
|
||||
* @param from the node from which to build the xpath
|
||||
* @param to an ancestor of <tt>from</tt> which will be the root of the path
|
||||
* @return an xpath to <tt>to</tt> rooted at <tt>from</tt>.
|
||||
*/
|
||||
public static String buildXPath(final Node from, final Element to)
|
||||
{
|
||||
String result = "";
|
||||
Node tmp = from;
|
||||
do
|
||||
{
|
||||
if (tmp instanceof Attr)
|
||||
{
|
||||
assert result.length() == 0;
|
||||
result = "@" + tmp.getNodeName();
|
||||
}
|
||||
else if (tmp instanceof Element)
|
||||
{
|
||||
Node tmp2 = tmp;
|
||||
int position = 1;
|
||||
while (tmp2.getPreviousSibling() != null)
|
||||
{
|
||||
if (tmp2.getNodeName().equals(tmp.getNodeName()))
|
||||
{
|
||||
position++;
|
||||
}
|
||||
tmp2 = tmp2.getPreviousSibling();
|
||||
}
|
||||
String part = tmp.getNodeName() + "[" + position + "]";
|
||||
result = "/" + part + result;
|
||||
}
|
||||
else if (tmp instanceof Text)
|
||||
{
|
||||
assert result.length() == 0;
|
||||
result = "/text()";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
throw new IllegalArgumentException("unsupported node type " + tmp);
|
||||
}
|
||||
}
|
||||
tmp = tmp.getParentNode();
|
||||
}
|
||||
while (tmp != to.getParentNode() && tmp != null);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static DocumentBuilder getDocumentBuilder(final boolean namespaceAware,
|
||||
final boolean validating)
|
||||
{
|
||||
try
|
||||
{
|
||||
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
dbf.setNamespaceAware(namespaceAware);
|
||||
dbf.setValidating(validating);
|
||||
return dbf.newDocumentBuilder();
|
||||
}
|
||||
catch (ParserConfigurationException pce)
|
||||
{
|
||||
LOGGER.error(pce);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a NodeList of multiple nodelists
|
||||
*/
|
||||
public static NodeList combine(final NodeList... nls)
|
||||
{
|
||||
|
||||
return new NodeList()
|
||||
{
|
||||
public Node item(final int index)
|
||||
{
|
||||
int offset = 0;
|
||||
for (int i = 0; i < nls.length; i++)
|
||||
{
|
||||
if (index - offset < nls[i].getLength())
|
||||
{
|
||||
return nls[i].item(index - offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
offset += nls[i].getLength();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
int result = 0;
|
||||
for (int i = 0; i < nls.length; i++)
|
||||
{
|
||||
result += nls[i].getLength();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@@ -24,6 +24,8 @@ import java.util.Random;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.util.XMLUtil;
|
||||
|
||||
/**
|
||||
* Simple XMLUtil test
|
||||
*/
|
||||
|
@@ -20,6 +20,7 @@ package org.alfresco.web.forms;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -54,6 +55,8 @@ import org.w3c.dom.traversal.NodeFilter;
|
||||
import org.w3c.dom.traversal.NodeIterator;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import org.alfresco.util.XMLUtil;
|
||||
|
||||
/**
|
||||
* A rendering engine which uses xsl templates to render renditions of
|
||||
* form instance data.
|
||||
@@ -258,14 +261,12 @@ public class XSLTRenderingEngine
|
||||
final Element docEl = xslTemplate.getDocumentElement();
|
||||
final String XALAN_NS = Constants.S_BUILTIN_EXTENSIONS_URL;
|
||||
final String XALAN_NS_PREFIX = "xalan";
|
||||
docEl.setAttribute("xmlns:" + XALAN_NS_PREFIX, XALAN_NS);
|
||||
|
||||
final Set<String> excludePrefixes = new HashSet<String>();
|
||||
if (docEl.hasAttribute("exclude-result-prefixes"))
|
||||
{
|
||||
excludePrefixes.addAll(Arrays.asList(docEl.getAttribute("exclude-result-prefixes").split(" ")));
|
||||
}
|
||||
excludePrefixes.add(XALAN_NS_PREFIX);
|
||||
|
||||
final List<String> result = new LinkedList<String>();
|
||||
for (QName ns : methods.keySet())
|
||||
@@ -384,7 +385,7 @@ public class XSLTRenderingEngine
|
||||
Document xslTemplate = null;
|
||||
try
|
||||
{
|
||||
xslTemplate = XMLUtil.parse(ret.getInputStream());
|
||||
xslTemplate = XMLUtil.secureParseXSL(ret.getInputStream());
|
||||
}
|
||||
catch (final SAXException sax)
|
||||
{
|
||||
|
@@ -42,7 +42,7 @@ import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.apache.commons.jxpath.JXPathContext;
|
||||
import org.apache.commons.jxpath.Pointer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@@ -26,7 +26,7 @@ import java.util.ResourceBundle;
|
||||
import junit.framework.AssertionFailedError;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.util.BaseTest;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.apache.commons.jxpath.JXPathContext;
|
||||
import org.apache.commons.jxpath.Pointer;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@@ -26,7 +26,7 @@ import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.xerces.xs.XSAttributeUse;
|
||||
|
@@ -49,7 +49,7 @@ import org.alfresco.web.bean.wcm.AVMNode;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
import org.alfresco.web.forms.Form;
|
||||
import org.alfresco.web.forms.FormProcessor;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.xerces.xs.XSModel;
|
||||
|
@@ -40,7 +40,7 @@ import org.alfresco.web.bean.wcm.AVMBrowseBean;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
import org.alfresco.web.forms.Form;
|
||||
import org.alfresco.web.forms.FormProcessor;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.alfresco.util.XMLUtil;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.chiba.xml.ns.NamespaceConstants;
|
||||
|
@@ -794,6 +794,51 @@
|
||||
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
|
||||
</user-data-constraint>
|
||||
</security-constraint>
|
||||
|
||||
<security-constraint>
|
||||
<web-resource-collection>
|
||||
<web-resource-name>SOLR</web-resource-name>
|
||||
<url-pattern>/s/api/solr/*</url-pattern>
|
||||
</web-resource-collection>
|
||||
|
||||
<auth-constraint>
|
||||
<role-name>repoclient</role-name>
|
||||
</auth-constraint>
|
||||
|
||||
<user-data-constraint>
|
||||
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
|
||||
</user-data-constraint>
|
||||
</security-constraint>
|
||||
|
||||
<security-constraint>
|
||||
<web-resource-collection>
|
||||
<web-resource-name>SOLR</web-resource-name>
|
||||
<url-pattern>/wcservice/api/solr/*</url-pattern>
|
||||
</web-resource-collection>
|
||||
|
||||
<auth-constraint>
|
||||
<role-name>repoclient</role-name>
|
||||
</auth-constraint>
|
||||
|
||||
<user-data-constraint>
|
||||
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
|
||||
</user-data-constraint>
|
||||
</security-constraint>
|
||||
|
||||
<security-constraint>
|
||||
<web-resource-collection>
|
||||
<web-resource-name>SOLR</web-resource-name>
|
||||
<url-pattern>/wcs/api/solr/*</url-pattern>
|
||||
</web-resource-collection>
|
||||
|
||||
<auth-constraint>
|
||||
<role-name>repoclient</role-name>
|
||||
</auth-constraint>
|
||||
|
||||
<user-data-constraint>
|
||||
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
|
||||
</user-data-constraint>
|
||||
</security-constraint>
|
||||
|
||||
<login-config>
|
||||
<auth-method>CLIENT-CERT</auth-method>
|
||||
|
@@ -89,9 +89,9 @@ function saveContent(id, content)
|
||||
<%-- Inline editor --%>
|
||||
<tr>
|
||||
<td width="100%" valign="top" height="100%">
|
||||
<div id='editor' style='width:100%; height:360px'>
|
||||
<textarea id='editor' style='width:100%; height:360px'>
|
||||
</f:verbatim><h:outputText value="#{CCProperties.documentContent}" escape="false" /><f:verbatim>
|
||||
</div>
|
||||
</textarea>
|
||||
</f:verbatim><h:inputHidden id="editorOutput" value="#{CCProperties.editorOutput}" /><f:verbatim>
|
||||
</td>
|
||||
</tr>
|
||||
|
51
source/web/yui/event.js
vendored
51
source/web/yui/event.js
vendored
@@ -1056,13 +1056,60 @@ if (!YAHOO.util.Event) {
|
||||
}
|
||||
}
|
||||
|
||||
var n = 100;
|
||||
if (recurse && el && el.childNodes) {
|
||||
for (i=0,len=el.childNodes.length; i<len ; ++i) {
|
||||
this.purgeElement(el.childNodes[i], recurse, sType);
|
||||
if (YAHOO.env.ua.ie > 8 || YAHOO.env.ua.ie == 0) {
|
||||
for (i=0,len=el.childNodes.length; i<len ; ++i) {
|
||||
this.purgeElement(el.childNodes[i], recurse, sType);
|
||||
}
|
||||
} else {
|
||||
var elements = new Array();
|
||||
this.gatherElements(el, elements);
|
||||
this.purgeElementBatch(elements, n, sType);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
purgeElementBatch: function(elements, n, sType) {
|
||||
var cycle = 0;
|
||||
while (elements.length > 0) {
|
||||
var elListeners = this.getListeners(elements[0], sType);
|
||||
if (elListeners) {
|
||||
for (var i=0,len=elListeners.length; i<len ; i++) {
|
||||
var l = elListeners[i];
|
||||
this.removeListener(elements[0], l.type, l.fn);
|
||||
}
|
||||
}
|
||||
elements.shift();
|
||||
cycle++;
|
||||
if (cycle == n) {
|
||||
var t = setTimeout(function(){YAHOO.util.Event.purgeElementBatch(elements, n, sType);}, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
gatherElements: function(el, elements) {
|
||||
var nodes = new Array();
|
||||
nodes.push(el);
|
||||
elements.push(el);
|
||||
var nextNodes = new Array();
|
||||
while (nodes.length > 0) {
|
||||
nextNodes.length = 0;
|
||||
for (var i=0, len=nodes.length; i<len; i++) {
|
||||
var curNode = nodes[i];
|
||||
if (curNode.childNodes) {
|
||||
for (var j=0, curLen=curNode.childNodes.length; j<curLen ; j++) {
|
||||
nextNodes.push(curNode.childNodes[j]);
|
||||
elements.push(curNode.childNodes[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes.length = 0;
|
||||
nodes = nextNodes.slice(0);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns all listeners attached to the given element via addListener.
|
||||
* Optionally, you can specify a specific type of event to return.
|
||||
|
Reference in New Issue
Block a user