Merged V4.1-BUG-FIX to HEAD

43386: ALF-13091: Prevent bean post processor propagation to child application contexts. Remove Jsr250BeanPostPorcessor from the CXF configuration, to prevent strange interaction with component scanning. 
   43402: Merged DEV to V4.1-BUG-FIX
      43330: ALF-16073: Share forms renders is slow when using sets.
      Optimize performance for fieldsVisibleInAnyMode populating in getFields and FormField obtaining in getVisibleFieldNamesFor.
   43412: ALF-16680 ImageMagick exit code 255 is not seen as an error 
   43420: ALF-16627 SOLR indexing does not provide TransformationOption when converting content to plain text for indexing
   43452: Fix for ALF-16296 - On site customization page, when a page containing apostrophe (') is renamed, a backslash (\) is added to the name
   43453: Fix for ALF-16105 - Disabled 'Follow' feature does not disable it for existing users
   43462: ALF-16715 : Merged V3.4-BUG-FIX (3.4.12) to V4.1-BUG-FIX (4.1.3)
      43461: ALF-16713 Cannot disable metadata extractors
   43464: ALF-16715 : Merged V3.4-BUG-FIX (3.4.12) to V4.1-BUG-FIX (4.1.3)
      43463: ALF-16713 Cannot disable metadata extractors
         - fix test failures - none set mimetypeService
   43471: Fix for ALF-16542 - Web application context for the onlineEditUrl variable is hard-coded to alfresco:
   Merged BRANCHES/DEV/CLOUD1_SP to BRANCHES/DEV/V4.1-BUG-FIX
      40565: CLOUD-23: core changes to allow overriding of "edit online" button's URL generation.
   43475: Fix for ALF-15859 - UploadContentServlet servlet /alfresco/upload can update the content, mime type and encoding but not the locale
   43476: Merged DEV to V4.1-BUG-FIX
       43401 : ALF-16587 GreenMail IMAP server does not clean up session handlers - memory leak
   43478: MNT-181: Now WebDAV will ALWAYS preserve the original metadata and versions of ANY node that is temporarily 'moved out' in ANY kind of 'shuffle' operation
   - To make the source node temporarily invisible to WebDAV the client specific HIDDEN aspect features are used
   - WebDAVHelper.isRenameShuffle() method introduced, to parallel ALF-3856 CIFS fix and using similar system.webdav.renameShufflePattern global property to detect the start of a shuffle
   - WebDAVHelper converted to use proper dependency injection
   - CopyMethod has become a simple subclass of MoveMethod as all the hidden aspect munging is done by it
   - DeleteMethod now preserves hidden nodes
   - PropFindMethod now ignores hidden nodes
   - Listing methods will hide hidden nodes from WebDAV
   43483: MNT-181: Corrected typo
   43498: Fix for ALF-16648 - Alfresco Enterprise artifacts in artifacts.alfresco.com do not provide POM files / dependencies declarations:
   Merged HEAD to V4.1-BUG-FIX (4.1.2)
      43380: -- added site content for alfresco-platform-distribution POM
      43379: -- added site documentation for alfresco-platform-distribution POM
      43378: -- added site documentation for alfresco-platform-distribution POM
         -- deployed site for 4.2.b Community at https://artifacts.alfresco.com/nexus/content/repositories/alfresco-docs/alfresco-platform-distribution/latest/index.html
         -- created repository for Enterprise docs and added url in the appropriate edition properties
      43273: Use property to define POI version
      42966: ALF-14353 - Added platform distribution POM to standard maven-deploy procedure
      42965: ALF-14353 - added alfresco-platform-distribution to provide a Maven release descriptor (dependencyManagement) per each Community / Enterprise release
         -- moved maven-ant-tasks not to be in the runtime lib
         -- added platform distribution pom in the SDK folder
         -- updated maven.xml to deploy filter and deploy the appropriate platform-distribution POM per each releae
         -- in maven.xml moved configure-release and configure-snapshot goals to maven-env-prerequisites
         -- updated sdk readme to explain the presence of alfresco-platform-distribution POM
      42912: -- updated README header on the POM specifying it's NOT usable to build Alfresco
         -- make a clear reference to the POMs that get deployed by pom-experimental.xml being usable for development
      42842: ALF-14353: Fix artifactId alfresco-jlan -> alfresco-jlan-embed
      41883: ALF-14353 - fixed multiple Maven build issues. Now mvn clean install -f pom-experimental.xml works fine. Also deployed Spring Surf 1.2.0-SNAPSHOT so proper Surf version is retrieved
      41882: added pre-requisites to build POMs successfully with mvn clean install -f pom-experimental.xml
   43499: Upgrade version in POM files to 4.1.3-SNAPSHOT
   43520: ALF-16694 POI becoming responsiveness and causing jvm to freeze for a while with certain XLS (fraction formats)
      - Patched POI to:
        - limit the length of fractions to four digits (more than that takes too long to process) e.g. "# #/#####" is too long and will be reduced to "# #/####" which still takes about a second!
        - handle the -ve fraction format part (i.e. n in p;n;z), so its length is not interpret as part of the fraction format of the +ve fraction part.
        - handle custom formats a bit better (strip them) rather than interpret the text length as part of the fraction format
        - handle -ve fractions (just did not work)
        - limitations:
          - custom text gets stripped (still better than before)
          - formats that have p (+ve) and n (-ve) parts must include a fraction format in each part. Otherwise +ve and -ve values are not formatted as a fraction (still better than before)
   43523: MNT-181: Corrections
   - WebDAVLockService.unlock() made 'harmless' to call on already-unlocked nodes
   - Delete method hides rather than deletes versioned nodes and working copes in case it is called by OSX Finder during a 'replace' operation
   43524: MNT-181: Correction
   - PutMethod now 'unhides' hidden nodes and behaves as though it created them
   43541: Merged DEV to V4.1-BUG-FIX
      43536: ALF-16200: WQS delete fails to publish to live projects onDeleteNode behavior
      The condition of "if" operator was modified. Now "if" operator evaluate to true if least one of the nodesToTransfer or nodesToRemoveOnTransfer sets is not empty. beforeDeleteNode() methods were updated for check for the ASPECT_PENDING_DELETE aspect on the node. enqueueRemovedNodes() call was moved from onDeleteNode() into beforeDeleteNode(). These fixes allow to automatically update the sites published to (i.e. live projects) to include the removal of the file and removal of file from any collection (asset list) when a content was deleted from an editorial project.
   43542: Fix for ALF-16618 - ScriptableHashMap does not have hasOwnProperty method
   43555: Fix for ALF-16494 - site collaborator has rights to modify comments made by another user.
   43556: ALF-15859: Prevent NPE on upload without NodeRef
   43558: ALF-16694 POI becoming irresponsive and causing jvm to freeze with XLS that includes fraction formats
      - Original jar did not get removed in previous commit
      << NO NEED TO MERGE TO CLOUD1-BUG-FIX as there was a tree conflict and the original jar was removed. >>
   43570: MNT-181: More corrections researched by Valery
   - Don't treat all moves to temporary locations as copies - just those from non-temporary locations. Avoids initial upload leaving lots of hidden files around.
   - Only copy the content, not the whole node including aspects to avoid versioning temporary files!
   - Don't version on changes to sys:clientVisibilityMask - avoids 'double versioning'
   - Recognize Mac .TemporaryItems folder and ._ files as temporary
   43575: Fix for ALF-9317 - Links: Delete Link button in Selected Items menu is available for Consumer, Contributor and Collaborator
   43577: Upgrade POM files after following changes:
      43401: ALF-16587 patch greenmail
      43520: ALF-16694 Uprade POI and patch it
   43584: Merged V4.1 to V4.1-BUG-FIX <<Record Only>>
      43582: Merged V4.1-BUG-FIX to V4.1 (4.1.2)
         43402: Merged DEV to V4.1-BUG-FIX
            43330: ALF-16073: Share forms renders is slow when using sets.
            Optimize performance for fieldsVisibleInAnyMode populating in getFields and FormField obtaining in getVisibleFieldNamesFor.
      43557: Merged V4.1-BUG-FIX to V4.1
         43555: Fix for ALF-16494 - site collaborator has rights to modify comments made by another user.
   43586: MNT-181: Final correction researched by Valery
   - Corrected system.webdav.renameShufflePattern so that it matches .TemporaryItems folder and ._ files as a full match
   43591: ALF-16772: If the WebDAV path of a document exceeds 255 characters, documents opened in MSOffice cannot be saved back
       - Interpret null nodeLockToken as not locked.
   43594: Merged DEV to V4.1-BUG-FIX
      43540: ALF-12425: Can't launch activiti workflow console from Share when external / ntlm / kerberos authentication is used.
      New webscript that redirects to activiti admin console with URL holding current ticket. The webscript resides below wcs and allows to use alfresco connector in Share.
      43562: ALF-12425: Can't launch activiti workflow console from Share when external / ntlm / kerberos authentication is used.
      Activiti admin console webscript that allows admin console to be invoked behind wcs authentication.
   43595: Merged V4.1 to V4.1-BUG-FIX
      43376: Merged DEV to V4.1
         43339: ALF-16590 : java.lang.IllegalArgumentException while initiating In-Place import
                FilesystemContentDataFactory#contentIsInStore method was modified. Now files' absolute paths are compared.
      43390: ALF-15856: Test org.alfresco.repo.node.NodeServiceTest does not finish on DB2
      - Now inner-nested retrying transaction in testConcurrentArchive passes its exception straight through to the outer transaction, which unwraps and retries it if necessary
      43397: ALF-16021: RuleServiceImplTest never ends on DB2
      - Added endTransaction() call so that testDeleteSpaceWithExecuteScriptRule() doesn't hang indefinitely waiting for the outer transaction to complete
      43398: ALF-15856: Test org.alfresco.repo.node.NodeServiceTest does not finish on DB2
      - Now inner-nested retrying transaction runs in its own thread and we don't wait forever for it
      43404: ALF-16666: IMAP subsystem startup causes Tomcat crash
      - Stopped IMAP subsystem from depending on itself by using private rather than public IMapService!
      43408: Fixed latest DB2 hangs for Samuel (concurrent nested transactions)
      43424: Fixed latest DB2 hang for Samuel (concurrent nested transactions)
      43426: ALF-16692: Merged HEAD to V4.1 (with corrections)
         43425: Fixes issue with YUI SWF files (see: IT-9441)
      43450: Possible fix for workflow tests on DB2 - retrying txns where necessary
      43484: ALF-16702: Restored missing index in DB2 schema reference
   43596: Merged V4.1 to V4.1-BUG-FIX (RECORD ONLY)
      43589: Merged V4.1-BUG-FIX to V4.1
         43575: Fix for ALF-9317 - Links: Delete Link button in Selected Items menu is available for Consumer, Contributor and Collaborator


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@43601 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2012-11-14 11:56:36 +00:00
parent 379b0c41c2
commit 0a7a676304
17 changed files with 634 additions and 328 deletions

View File

@@ -5,7 +5,7 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:alfresco/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

129
config/alfresco/cxf/cxf.xml Normal file
View File

@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
This file is an emanded copy of META-INF/cxf/cxf.xml from cxf-2.2.2-patched.jar.
It removes the Jsr250BeanPostProcessor and fixes up the other beans which rely on it for initialization.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:foo="http://cxf.apache.org/configuration/foo"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"/>
<bean id="org.apache.cxf.bus.spring.BusApplicationListener" class="org.apache.cxf.bus.spring.BusApplicationListener"/>
<bean id="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor" class="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor"/>
<bean id="org.apache.cxf.bus.spring.BusExtensionPostProcessor" class="org.apache.cxf.bus.spring.BusExtensionPostProcessor"/>
<bean id="org.apache.cxf.resource.ResourceManager" class="org.apache.cxf.bus.resource.ResourceManagerImpl">
<property name="resolvers">
<list>
<bean class="org.apache.cxf.resource.ClasspathResolver"/>
<bean class="org.apache.cxf.resource.ClassLoaderResolver"/>
<bean class="org.apache.cxf.bus.spring.BusApplicationContextResourceResolver"/>
</list>
</property>
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.configuration.Configurer"
class="org.apache.cxf.configuration.spring.ConfigurerImpl">
</bean>
<bean id="org.apache.cxf.binding.BindingFactoryManager" class="org.apache.cxf.binding.BindingFactoryManagerImpl">
<property name="mapProvider">
<bean class="org.apache.cxf.configuration.spring.SpringBeanMap">
<property name="type" value="org.apache.cxf.binding.BindingFactory"/>
<property name="idsProperty" value="activationNamespaces"/>
</bean>
</property>
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.transport.DestinationFactoryManager" class="org.apache.cxf.transport.DestinationFactoryManagerImpl">
<property name="mapProvider">
<bean class="org.apache.cxf.configuration.spring.SpringBeanMap">
<property name="type" value="org.apache.cxf.transport.DestinationFactory"/>
<property name="idsProperty" value="transportIds"/>
</bean>
</property>
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.transport.ConduitInitiatorManager" class="org.apache.cxf.transport.ConduitInitiatorManagerImpl">
<property name="mapProvider">
<bean class="org.apache.cxf.configuration.spring.SpringBeanMap">
<property name="type" value="org.apache.cxf.transport.ConduitInitiator"/>
<property name="idsProperty" value="transportIds"/>
</bean>
</property>
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.wsdl.WSDLManager" class="org.apache.cxf.wsdl11.WSDLManagerImpl">
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.phase.PhaseManager" class="org.apache.cxf.phase.PhaseManagerImpl">
</bean>
<bean id="org.apache.cxf.workqueue.WorkQueueManager" class="org.apache.cxf.workqueue.WorkQueueManagerImpl">
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.buslifecycle.BusLifeCycleManager" class="org.apache.cxf.buslifecycle.CXFBusLifeCycleManager">
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.endpoint.ServerRegistry" class="org.apache.cxf.endpoint.ServerRegistryImpl">
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.endpoint.ServerLifeCycleManager" class="org.apache.cxf.endpoint.ServerLifeCycleManagerImpl"/>
<bean id="org.apache.cxf.endpoint.ClientLifeCycleManager" class="org.apache.cxf.endpoint.ClientLifeCycleManagerImpl"/>
<bean id="org.apache.cxf.transports.http.QueryHandlerRegistry" class="org.apache.cxf.transport.http.QueryHandlerRegistryImpl">
<property name="bus" ref="cxf"/>
<property name="queryHandlers">
<list>
<bean class="org.apache.cxf.transport.http.WSDLQueryHandler">
<property name="bus" ref="cxf"/>
</bean>
</list>
</property>
</bean>
<bean id="org.apache.cxf.endpoint.EndpointResolverRegistry" class="org.apache.cxf.endpoint.EndpointResolverRegistryImpl">
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.headers.HeaderManager" class="org.apache.cxf.headers.HeaderManagerImpl">
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.catalog.OASISCatalogManager" class="org.apache.cxf.catalog.OASISCatalogManager">
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.endpoint.ServiceContractResolverRegistry" class="org.apache.cxf.endpoint.ServiceContractResolverRegistryImpl" init-method="init">
<property name="bus" ref="cxf"/>
</bean>
</beans>

View File

@@ -25,10 +25,51 @@
<property name="lockStoreFactory" ref="webdavLockStoreFactory"/>
</bean>
<bean id="webDAVHelper" class="org.alfresco.repo.webdav.WebDAVHelper">
<constructor-arg value="${system.webdav.url.path.prefix}"/>
<constructor-arg ref="ServiceRegistry"/>
<constructor-arg ref="authenticationService"/>
<constructor-arg ref="tenantService"/>
</bean>
<bean id="webDAVHelper" class="org.alfresco.repo.webdav.WebDAVHelper">
<property name="serviceRegistry">
<ref bean="ServiceRegistry" />
</property>
<property name="nodeService">
<ref bean="NodeService" />
</property>
<property name="fileFolderService">
<ref bean="FileFolderService" />
</property>
<property name="searchService">
<ref bean="SearchService" />
</property>
<property name="namespaceService">
<ref bean="NamespaceService" />
</property>
<property name="dictionaryService">
<ref bean="DictionaryService" />
</property>
<property name="mimetypeService">
<ref bean="MimetypeService" />
</property>
<property name="lockService">
<ref bean="webDAVLockService" />
</property>
<property name="actionService">
<ref bean="ActionService" />
</property>
<property name="permissionService">
<ref bean="PermissionService" />
</property>
<property name="hiddenAspect">
<ref bean="hiddenAspect" />
</property>
<property name="authenticationService">
<ref bean="authenticationService" />
</property>
<property name="tenantService">
<ref bean="tenantService" />
</property>
<property name="renameShufflePattern">
<value>${system.webdav.renameShufflePattern}</value>
</property>
<property name="urlPathPrefix">
<value>${system.webdav.url.path.prefix}</value>
</property>
</bean>
</beans>

View File

@@ -43,7 +43,7 @@
"edit": false,
"delete": false
<#else>
"edit": ${item.node.hasPermission("Write")?string},
"edit": ${item.canEditComment?string},
"delete": ${item.node.hasPermission("Delete")?string}
</#if>
}

View File

@@ -63,6 +63,8 @@ function getCommentData(node)
data.node = node;
data.author = people.getPerson(node.properties["cm:creator"]);
data.isUpdated = (node.properties["cm:modified"] - node.properties["cm:created"]) > 5000;
data.canEditComment = (person == data.owner) || (person == data.author) ||
node.hasPermission("SiteManager") || node.hasPermission("Coordinator");
return data;
}

View File

@@ -1532,6 +1532,7 @@
<property name="contentService" ref="contentService"/>
<property name="nodeService" ref="nodeService"/>
<property name="nodeDAO" ref="nodeDAO"/>
<property name="transformerDebug" ref="transformerDebug" />
</bean>
<bean id="webscript.org.alfresco.repository.solr.model.get"

View File

@@ -21,6 +21,7 @@ package org.alfresco.repo.web.scripts.solr;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletResponse;
@@ -28,6 +29,7 @@ import javax.servlet.http.HttpServletResponse;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.content.transform.ContentTransformer;
import org.alfresco.repo.content.transform.TransformerDebug;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.web.scripts.content.StreamContent;
import org.alfresco.service.cmr.repository.ContentIOException;
@@ -36,6 +38,7 @@ import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.apache.commons.httpclient.HttpStatus;
@@ -67,6 +70,7 @@ public class NodeContentGet extends StreamContent
private NodeDAO nodeDAO;
private NodeService nodeService;
private ContentService contentService;
private TransformerDebug transformerDebug;
public void setNodeDAO(NodeDAO nodeDAO)
{
@@ -82,6 +86,15 @@ public class NodeContentGet extends StreamContent
{
this.contentService = contentService;
}
/**
* Setter of the transformer debug.
* @param transformerDebug
*/
public void setTransformerDebug(TransformerDebug transformerDebug)
{
this.transformerDebug = transformerDebug;
}
/**
* @in
@@ -157,54 +170,69 @@ public class NodeContentGet extends StreamContent
return;
}
ContentTransformer transformer = contentService.getTransformer(reader.getMimetype(), MimetypeMap.MIMETYPE_TEXT_PLAIN);
if(transformer == null)
{
res.setHeader(TRANSFORM_STATUS_HEADER, "noTransform");
res.setStatus(HttpStatus.SC_NO_CONTENT);
return;
}
// Perform transformation catering for mimetype AND encoding
ContentWriter writer = contentService.getTempWriter();
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
writer.setEncoding("UTF-8"); // Expect transformers to produce UTF-8
try
{
long start = System.currentTimeMillis();
transformer.transform(reader, writer);
long transformDuration = System.currentTimeMillis() - start;
res.setHeader(TRANSFORM_DURATION_HEADER, String.valueOf(transformDuration));
}
catch (ContentIOException e)
{
transformException = e;
}
// get the transformer
TransformationOptions options = new TransformationOptions();
options.setSourceNodeRef(nodeRef);
transformerDebug.pushAvailable(reader.getContentUrl(), reader.getMimetype(), MimetypeMap.MIMETYPE_TEXT_PLAIN, options);
long sourceSize = reader.getSize();
List<ContentTransformer> transformers = contentService.getActiveTransformers(reader.getMimetype(), sourceSize, MimetypeMap.MIMETYPE_TEXT_PLAIN, options);
transformerDebug.availableTransformers(transformers, sourceSize, "NodeContentGet");
if(transformException == null)
{
// point the reader to the new-written content
textReader = writer.getReader();
// Check that the reader is a view onto something concrete
if (textReader == null || !textReader.exists())
if (transformers.isEmpty())
{
transformException = new ContentIOException(
"The transformation did not write any content, yet: \n"
+ " transformer: " + transformer + "\n" + " temp writer: " + writer);
res.setHeader(TRANSFORM_STATUS_HEADER, "noTransform");
res.setStatus(HttpStatus.SC_NO_CONTENT);
return;
}
ContentTransformer transformer = transformers.get(0);
// Perform transformation catering for mimetype AND encoding
ContentWriter writer = contentService.getTempWriter();
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
writer.setEncoding("UTF-8"); // Expect transformers to produce UTF-8
try
{
long start = System.currentTimeMillis();
transformer.transform(reader, writer);
long transformDuration = System.currentTimeMillis() - start;
res.setHeader(TRANSFORM_DURATION_HEADER, String.valueOf(transformDuration));
}
catch (ContentIOException e)
{
transformException = e;
}
if(transformException == null)
{
// point the reader to the new-written content
textReader = writer.getReader();
// Check that the reader is a view onto something concrete
if (textReader == null || !textReader.exists())
{
transformException = new ContentIOException(
"The transformation did not write any content, yet: \n"
+ " transformer: " + transformer + "\n" + " temp writer: " + writer);
}
}
if(transformException != null)
{
res.setHeader(TRANSFORM_STATUS_HEADER, "transformFailed");
res.setHeader(TRANSFORM_EXCEPTION_HEADER, transformException.getMessage());
res.setStatus(HttpStatus.SC_NO_CONTENT);
}
else
{
res.setStatus(HttpStatus.SC_OK);
streamContentImpl(req, res, textReader, false, modified, String.valueOf(modified.getTime()), null);
}
}
if(transformException != null)
finally
{
res.setHeader(TRANSFORM_STATUS_HEADER, "transformFailed");
res.setHeader(TRANSFORM_EXCEPTION_HEADER, transformException.getMessage());
res.setStatus(HttpStatus.SC_NO_CONTENT);
}
else
{
res.setStatus(HttpStatus.SC_OK);
streamContentImpl(req, res, textReader, false, modified, String.valueOf(modified.getTime()), null);
transformerDebug.popAvailable();
}
}
}

View File

@@ -1,186 +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.repo.webdav;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
/**
* Implements the WebDAV COPY and MOVE methods
*
* @author Derek Hulley
*/
public abstract class AbstractMoveOrCopyMethod extends HierarchicalMethod
{
/**
* Default constructor
*/
public AbstractMoveOrCopyMethod()
{
}
/**
* Implement the move or copy, depending on the implementation
*
* @param fileFolderService the service to do the work
* @param sourceNodeRef the node to copy or move
* @param destParentNodeRef the destination parent
* @param name the name of the file or folder
* @throws Exception
*/
protected abstract void moveOrCopy(
FileFolderService fileFolderService,
NodeRef sourceNodeRef,
NodeRef sourceParentNodeRef,
NodeRef destParentNodeRef,
String name) throws Exception;
/**
* Exceute the request
*
* @exception WebDAVServerException
*/
protected final void executeImpl() throws WebDAVServerException, Exception
{
FileFolderService fileFolderService = getFileFolderService();
NodeRef rootNodeRef = getRootNodeRef();
String servletPath = getServletPath();
// Debug
if (logger.isDebugEnabled())
{
logger.debug("Copy from " + getPath() + " to " + getDestinationPath());
}
// the source must exist
String sourcePath = getPath();
FileInfo sourceInfo = null;
try
{
sourceInfo = getDAVHelper().getNodeForPath(rootNodeRef, sourcePath, servletPath);
}
catch (FileNotFoundException e)
{
throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
}
FileInfo sourceParentInfo = getDAVHelper().getParentNodeForPath(rootNodeRef, sourcePath, servletPath);
// the destination parent must exist
String destPath = getDestinationPath();
FileInfo destParentInfo = null;
try
{
if (destPath.endsWith(WebDAVHelper.PathSeperator))
{
destPath = destPath.substring(0, destPath.length() - 1);
}
destParentInfo = getDAVHelper().getParentNodeForPath(rootNodeRef, destPath, servletPath);
}
catch (FileNotFoundException e)
{
if (logger.isDebugEnabled())
{
logger.debug("Destination parent folder doesn't exist: " + destPath);
}
throw new WebDAVServerException(HttpServletResponse.SC_CONFLICT);
}
// check for the existence of the destination node
FileInfo destInfo = null;
try
{
destInfo = getDAVHelper().getNodeForPath(rootNodeRef, destPath, servletPath);
if (!destInfo.getNodeRef().equals(sourceInfo.getNodeRef()))
{
// ALF-7079 fix, if destInfo is working copy then content will be updated later
boolean isDestWorkingCopy = getNodeService().hasAspect(destInfo.getNodeRef(), ContentModel.ASPECT_WORKING_COPY);
if (!hasOverWrite() && !isDestWorkingCopy)
{
if (logger.isDebugEnabled())
{
logger.debug("Destination exists but overwrite is not allowed");
}
// it exists and we may not overwrite
throw new WebDAVServerException(HttpServletResponse.SC_PRECONDITION_FAILED);
}
// delete the destination node if it is not the same as the source node and not a working copy
if (!isDestWorkingCopy && !isShuffleOperation(sourceInfo) && !isVersioned(destInfo))
{
checkNode(destInfo);
// attempting to move or copy onto another node
fileFolderService.delete(destInfo.getNodeRef());
}
}
}
catch (FileNotFoundException e)
{
// destination doesn't exist
}
NodeRef sourceNodeRef = sourceInfo.getNodeRef();
NodeRef sourceParentNodeRef = sourceParentInfo.getNodeRef();
NodeRef destParentNodeRef = destParentInfo.getNodeRef();
String name = getDAVHelper().splitPath(destPath)[1];
moveOrCopy(fileFolderService, sourceNodeRef, sourceParentNodeRef, destParentNodeRef, name);
// Set the response status
if (destInfo == null)
{
m_response.setStatus(HttpServletResponse.SC_CREATED);
}
else
{
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
}
protected boolean isVersioned(FileInfo fileInfo)
{
NodeService nodeService = getNodeService();
boolean versioned = nodeService.hasAspect(fileInfo.getNodeRef(), ContentModel.ASPECT_VERSIONABLE);
return versioned;
}
protected boolean isShuffleOperation(FileInfo sourceInfo)
{
NodeService nodeService = getNodeService();
boolean hidden = nodeService.hasAspect(sourceInfo.getNodeRef(), ContentModel.ASPECT_HIDDEN);
boolean temporary = nodeService.hasAspect(sourceInfo.getNodeRef(), ContentModel.ASPECT_TEMPORARY);
boolean shuffleOperation = hidden && temporary;
return shuffleOperation;
}
protected void parseRequestHeaders() throws WebDAVServerException
{
super.parseRequestHeaders();
parseIfHeader();
}
}

View File

@@ -26,7 +26,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
*
* @author Derek Hulley
*/
public class CopyMethod extends AbstractMoveOrCopyMethod
public class CopyMethod extends MoveMethod
{
/**
* Default constructor
@@ -35,14 +35,13 @@ public class CopyMethod extends AbstractMoveOrCopyMethod
{
}
/*
* (non-Javadoc)
* @see org.alfresco.repo.webdav.MoveMethod#isMove()
*/
@Override
protected void moveOrCopy(
FileFolderService fileFolderService,
NodeRef sourceNodeRef,
NodeRef sourceParentNodeRef,
NodeRef destParentNodeRef,
String name) throws Exception
protected boolean isMove()
{
fileFolderService.copy(sourceNodeRef, destParentNodeRef, name);
return false;
}
}

View File

@@ -29,6 +29,7 @@ import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.cmr.webdav.WebDavService;
import org.alfresco.service.cmr.repository.NodeService;
/**
* Implements the WebDAV DELETE method
@@ -101,18 +102,30 @@ public class DeleteMethod extends WebDAVMethod implements ActivityPostProducer
checkNode(fileInfo);
// ALF-7079 fix, working copies are not deleted at all
if (!getNodeService().hasAspect(fileInfo.getNodeRef(), ContentModel.ASPECT_WORKING_COPY))
NodeService nodeService = getNodeService();
NodeRef nodeRef = fileInfo.getNodeRef();
// MNT-181: working copies and versioned nodes are hidden rather than deleted
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY) || nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
{
setHidden(nodeRef, true);
getDAVLockService().unlock(nodeRef);
}
// We just ensure already-hidden nodes are left unlocked
else if (isHidden(nodeRef))
{
getDAVLockService().unlock(nodeRef);
}
// A 'real' delete
else
{
// As this content will be deleted, we need to extract some info before it's no longer available.
String siteId = getSiteId();
NodeRef deletedNodeRef = fileInfo.getNodeRef();
FileInfo parentFile = getDAVHelper().getParentNodeForPath(getRootNodeRef(), getPath(), getServletPath());
boolean hidden = fileInfo.isHidden();
FileInfo parentFile = getDAVHelper().getParentNodeForPath(getRootNodeRef(), path, getServletPath());
// Delete it
fileFolderService.delete(deletedNodeRef);
// Don't post activity data for hidden files, resource forks etc.
if (!hidden)
if (!getDAVHelper().isRenameShuffle(path))
{
postActivity(parentFile, fileInfo, siteId);
}

View File

@@ -31,7 +31,6 @@ import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.dom4j.DocumentHelper;
import org.dom4j.io.XMLWriter;
import org.xml.sax.Attributes;
@@ -40,8 +39,9 @@ import org.xml.sax.Attributes;
* Implements the WebDAV MOVE method
*
* @author Derek Hulley
* @author David Ward
*/
public class MoveMethod extends AbstractMoveOrCopyMethod
public class MoveMethod extends HierarchicalMethod
{
/**
* Default constructor
@@ -49,14 +49,120 @@ public class MoveMethod extends AbstractMoveOrCopyMethod
public MoveMethod()
{
}
protected boolean isMove()
{
return true;
}
/**
* Exceute the request
*
* @exception WebDAVServerException
*/
protected final void executeImpl() throws WebDAVServerException, Exception
{
NodeRef rootNodeRef = getRootNodeRef();
String servletPath = getServletPath();
// Debug
if (logger.isDebugEnabled())
{
logger.debug((isMove() ? "Move" : "Copy") + " from " + getPath() + " to " + getDestinationPath());
}
// the source must exist
String sourcePath = getPath();
FileInfo sourceInfo = null;
try
{
sourceInfo = getDAVHelper().getNodeForPath(rootNodeRef, sourcePath, servletPath);
}
catch (FileNotFoundException e)
{
throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
}
FileInfo sourceParentInfo = getDAVHelper().getParentNodeForPath(rootNodeRef, sourcePath, servletPath);
// the destination parent must exist
String destPath = getDestinationPath();
FileInfo destParentInfo = null;
try
{
if (destPath.endsWith(WebDAVHelper.PathSeperator))
{
destPath = destPath.substring(0, destPath.length() - 1);
}
destParentInfo = getDAVHelper().getParentNodeForPath(rootNodeRef, destPath, servletPath);
}
catch (FileNotFoundException e)
{
if (logger.isDebugEnabled())
{
logger.debug("Destination parent folder doesn't exist: " + destPath);
}
throw new WebDAVServerException(HttpServletResponse.SC_CONFLICT);
}
// check for the existence of the destination node
FileInfo destInfo = null;
boolean destExists = false;
try
{
destInfo = getDAVHelper().getNodeForPath(rootNodeRef, destPath, servletPath);
if (!destInfo.getNodeRef().equals(sourceInfo.getNodeRef()))
{
// ALF-7079 fix, if destInfo is a hidden shuffle target then pretend it's not there
destExists = !isHidden(destInfo.getNodeRef());
if (!hasOverWrite() && destExists)
{
if (logger.isDebugEnabled())
{
logger.debug("Destination exists but overwrite is not allowed");
}
// it exists and we may not overwrite
throw new WebDAVServerException(HttpServletResponse.SC_PRECONDITION_FAILED);
}
checkNode(destInfo);
}
}
catch (FileNotFoundException e)
{
// destination doesn't exist
}
NodeRef sourceNodeRef = sourceInfo.getNodeRef();
NodeRef sourceParentNodeRef = sourceParentInfo.getNodeRef();
NodeRef destParentNodeRef = destParentInfo.getNodeRef();
String name = getDAVHelper().splitPath(destPath)[1];
moveOrCopy(sourceNodeRef, sourceParentNodeRef, destParentNodeRef, name);
// Set the response status
if (!destExists)
{
m_response.setStatus(HttpServletResponse.SC_CREATED);
}
else
{
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
}
protected void parseRequestHeaders() throws WebDAVServerException
{
super.parseRequestHeaders();
parseIfHeader();
}
protected void moveOrCopy(
FileFolderService fileFolderService,
NodeRef sourceNodeRef,
NodeRef sourceParentNodeRef,
NodeRef destParentNodeRef,
String name) throws Exception
{
FileFolderService fileFolderService = getFileFolderService();
NodeRef rootNodeRef = getRootNodeRef();
String sourcePath = getPath();
@@ -67,8 +173,8 @@ public class MoveMethod extends AbstractMoveOrCopyMethod
List<String> destPathElements = getDAVHelper().splitAllPaths(destPath);
FileInfo destFileInfo = null;
NodeService nodeService = getNodeService();
boolean isMove = isMove();
try
{
// get the node to move
@@ -87,12 +193,40 @@ public class MoveMethod extends AbstractMoveOrCopyMethod
throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
}
}
if (isMove)
{
checkNode(sourceFileInfo);
}
// ALF-7079 fix, if destination exists then its content is updated with source content and source is deleted if
// this is a move
if (destFileInfo != null)
{
copyContentOnly(sourceNodeRef, destFileInfo, fileFolderService);
setHidden(destFileInfo.getNodeRef(), false);
if (isMove)
{
fileFolderService.delete(sourceNodeRef);
}
}
// If this is a copy then the source is just copied to destination.
else if (!isMove)
{
fileFolderService.copy(sourceNodeRef, destParentNodeRef, name);
}
// If this is a move and the destination looks like the start of a shuffle operation, then the source is just
// copied to destination and the source is hidden.
else if (getDAVHelper().isRenameShuffle(destPath) && !getDAVHelper().isRenameShuffle(sourcePath))
{
destFileInfo = fileFolderService.create(destParentNodeRef, name, ContentModel.TYPE_CONTENT);
copyContentOnly(sourceNodeRef, destFileInfo, fileFolderService);
setHidden(sourceNodeRef, true);
checkNode(sourceFileInfo);
if (sourceParentNodeRef.equals(destParentNodeRef))
// As per the WebDAV spec, we make sure the node is unlocked once moved
getDAVHelper().getLockService().unlock(sourceNodeRef);
}
else if (sourceParentNodeRef.equals(destParentNodeRef))
{
// It is rename method
// It is a simple rename operation
try
{
fileFolderService.rename(sourceNodeRef, name);
@@ -111,43 +245,23 @@ public class MoveMethod extends AbstractMoveOrCopyMethod
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_ERROR, WebDAV.XML_NS_ERROR);
m_response.setStatus(HttpServletResponse.SC_CONFLICT);
return;
}
}
else if (destFileInfo != null && (isShuffleOperation(sourceFileInfo) || isVersioned(destFileInfo)))
{
copyOnlyContent(sourceNodeRef, destFileInfo, fileFolderService);
}
else
// ALF-7079 fix, if source is working copy then it is just copied to destination
if (nodeService.hasAspect(sourceNodeRef, ContentModel.ASPECT_WORKING_COPY))
{
// replace move with copy action for working copies
fileFolderService.copy(sourceNodeRef, destParentNodeRef, name);
}
// ALF-7079 fix, if destination exists and is working copy then its content is updated with
// source content and source is deleted
else if (destFileInfo != null && nodeService.hasAspect(destFileInfo.getNodeRef(), ContentModel.ASPECT_WORKING_COPY))
{
// copy only content for working copy destination
copyOnlyContent(sourceNodeRef, destFileInfo, fileFolderService);
}
else
{
// It is a simple move operation
fileFolderService.moveFrom(sourceNodeRef, sourceParentNodeRef, destParentNodeRef, name);
// As per the WebDAV spec, we make sure the node is unlocked once moved
getDAVHelper().getLockService().unlock(sourceNodeRef);
}
// As per the WebDAV spec, we make sure the node is unlocked once moved
getDAVHelper().getLockService().unlock(sourceNodeRef);
}
private void copyOnlyContent(NodeRef sourceNodeRef, FileInfo destFileInfo, FileFolderService fileFolderService)
private void copyContentOnly(NodeRef sourceNodeRef, FileInfo destFileInfo, FileFolderService fileFolderService)
{
ContentService contentService = getContentService();
ContentReader reader = contentService.getReader(sourceNodeRef, ContentModel.PROP_CONTENT);
ContentWriter contentWriter = contentService.getWriter(destFileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true);
contentWriter.putContent(reader);
fileFolderService.delete(sourceNodeRef);
}
}

View File

@@ -36,7 +36,6 @@ import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.repository.datatype.TypeConverter;
import org.alfresco.service.namespace.QName;
@@ -195,6 +194,13 @@ public class PropFindMethod extends WebDAVMethod
// The path is not valid - send a 404 error back to the client
throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
}
// A node hidden during a 'shuffle' operation - send a 404 error back to the client, as some Mac clients need
// this
if (isHidden(pathNodeInfo.getNodeRef()))
{
throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
}
// Set the response content type

View File

@@ -164,7 +164,14 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer
}
checkNode(contentNodeInfo);
// 'Unhide' hidden nodes and behave as though we created them
NodeRef contentNodeRef = contentNodeInfo.getNodeRef();
if (isHidden(contentNodeRef))
{
setHidden(contentNodeRef, false);
created = true;
}
}
catch (FileNotFoundException e)
{

View File

@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -34,10 +35,12 @@ import javax.servlet.http.HttpServletResponse;
import org.alfresco.jlan.util.IPAddress;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.lock.LockUtils;
import org.alfresco.repo.model.filefolder.HiddenAspect;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
@@ -52,7 +55,6 @@ import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.EqualsHelper;
import org.alfresco.util.Pair;
import org.apache.commons.lang.NotImplementedException;
@@ -73,9 +75,13 @@ import org.xml.sax.helpers.AttributesImpl;
public class WebDAVHelper
{
// Constants
public static final String BEAN_NAME = "webDAVHelper";
private static final String HTTPS_SCHEME = "https://";
private static final String HTTP_SCHEME = "http://";
// Path seperator
public static final String PathSeperator = "/";
public static final char PathSeperatorChar = '/';
@@ -84,7 +90,7 @@ public class WebDAVHelper
// Logging
private static Log logger = LogFactory.getLog("org.alfresco.webdav.protocol");
// Service registry
// Service registry TODO: eliminate this - not dependency injection!
private ServiceRegistry m_serviceRegistry;
// Services
@@ -99,33 +105,30 @@ public class WebDAVHelper
private AuthenticationService m_authService;
private PermissionService m_permissionService;
private TenantService m_tenantService;
private HiddenAspect m_hiddenAspect;
// pattern is tested against full path after it has been lower cased.
private Pattern m_renameShufflePattern = Pattern.compile("(.*/\\..*)|(.*[a-f0-9]{8}+$)|(.*\\.tmp$)|(.*\\.wbk$)|(.*\\.bak$)|(.*\\~$)");
// Empty XML attribute list
private AttributesImpl m_nullAttribs = new AttributesImpl();
private final AttributesImpl m_nullAttribs = new AttributesImpl();
private String m_urlPathPrefix;
/**
* Class constructor
*/
protected WebDAVHelper(String urlPathPrefix, ServiceRegistry serviceRegistry, AuthenticationService authService, TenantService tenantService)
{
m_serviceRegistry = serviceRegistry;
m_nodeService = m_serviceRegistry.getNodeService();
m_fileFolderService = m_serviceRegistry.getFileFolderService();
m_searchService = m_serviceRegistry.getSearchService();
m_namespaceService = m_serviceRegistry.getNamespaceService();
m_dictionaryService = m_serviceRegistry.getDictionaryService();
m_mimetypeService = m_serviceRegistry.getMimetypeService();
m_lockService = (WebDAVLockService)m_serviceRegistry.getService(QName.createQName(NamespaceService.ALFRESCO_URI, WebDAVLockService.BEAN_NAME));
m_actionService = m_serviceRegistry.getActionService();
m_permissionService = m_serviceRegistry.getPermissionService();
m_tenantService = tenantService;
m_authService = authService;
m_urlPathPrefix = urlPathPrefix;
/**
* Set the regular expression that will be applied to filenames during renames
* to detect whether clients are performing a renaming shuffle - common during
* file saving on various clients.
* <p/>
* <bALF-3856, ALF-7079, MNT-181</b>
*
* @param renameShufflePattern a regular expression filename match
*/
public void setRenameShufflePattern(Pattern renameShufflePattern)
{
this.m_renameShufflePattern = renameShufflePattern;
}
/**
* @return Return the authentication service
*/
@@ -139,6 +142,7 @@ public class WebDAVHelper
*/
public final ServiceRegistry getServiceRegistry()
{
// TODO: eliminate this - not dependency injection!
return m_serviceRegistry;
}
@@ -211,7 +215,15 @@ public class WebDAVHelper
{
return m_permissionService;
}
/**
* @return the hidden aspect bean
*/
public final HiddenAspect getHiddenAspect()
{
return m_hiddenAspect;
}
/**
* Retrieve the {@link TenantService} held by the helper.
*
@@ -230,6 +242,118 @@ public class WebDAVHelper
return getServiceRegistry().getCopyService();
}
public void setTenantService(TenantService tenantService)
{
this.m_tenantService = tenantService;
}
/**
* @param serviceRegistry the service registry
*/
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
this.m_serviceRegistry = serviceRegistry;
}
/**
* @param nodeService the node service
*/
public void setNodeService(NodeService nodeService)
{
this.m_nodeService = nodeService;
}
/**
* @param fileFolderService the fileFolder service
*/
public void setFileFolderService(FileFolderService fileFolderService)
{
this.m_fileFolderService = fileFolderService;
}
/**
* @param searchService the search service
*/
public void setSearchService(SearchService searchService)
{
this.m_searchService = searchService;
}
/**
* @param namespaceService the namespace service
*/
public void setNamespaceService(NamespaceService namespaceService)
{
this.m_namespaceService = namespaceService;
}
/**
* @param dictionaryService the dictionary service
*/
public void setDictionaryService(DictionaryService dictionaryService)
{
this.m_dictionaryService = dictionaryService;
}
/**
* @param mimetypeService the mimetype service
*/
public void setMimetypeService(MimetypeService mimetypeService)
{
this.m_mimetypeService = mimetypeService;
}
/**
* @param lockService the lock service
*/
public void setLockService(WebDAVLockService lockService)
{
this.m_lockService = lockService;
}
/**
* @param actionService the action service
*/
public void setActionService(ActionService actionService)
{
this.m_actionService = actionService;
}
/**
* @param authService the authentication service
*/
public void setAuthenticationService(AuthenticationService authService)
{
this.m_authService = authService;
}
/**
* @param permissionService the permission service
*/
public void setPermissionService(PermissionService permissionService)
{
this.m_permissionService = permissionService;
}
/**
* @param hiddenAspect the hiddenAspect to set
*/
public void setHiddenAspect(HiddenAspect hiddenAspect)
{
this.m_hiddenAspect = hiddenAspect;
}
/**
* Checks a new path in a move operation to detect whether clients are starting a renaming shuffle - common during
* file saving on various clients.
* <p/>
* <b>ALF-3856, ALF-7079, MNT-181</b>
*/
public boolean isRenameShuffle(String newPath)
{
return m_renameShufflePattern.matcher(newPath.toLowerCase()).matches();
}
/**
* Split the path into seperate directory path and file name strings.
* If the path is not empty, then there will always be an entry for the filename

View File

@@ -20,13 +20,9 @@ package org.alfresco.repo.webdav;
import static org.junit.Assert.assertEquals;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.mock.web.MockHttpServletRequest;
@@ -39,21 +35,18 @@ import org.springframework.mock.web.MockHttpServletRequest;
public class WebDAVHelperTest
{
private WebDAVHelper davHelper;
private @Mock ServiceRegistry serviceRegistry;
private @Mock AuthenticationService authService;
private @Mock TenantService tenantService;
@Before
public void setUp() throws Exception
{
davHelper = new WebDAVHelper("", serviceRegistry, authService, tenantService);
davHelper = new WebDAVHelper();
}
@Test
public void canGetUrlPathPrefixWhenExplicitlySet()
{
// Path prefix explicitly set on helper.
davHelper = new WebDAVHelper("/my/prefix", serviceRegistry, authService, tenantService);
davHelper.setUrlPathPrefix("/my/prefix");
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/my/prefix/folder/filename.txt");
String prefix = davHelper.getUrlPathPrefix(request);
assertEquals("/my/prefix/", prefix);
@@ -63,7 +56,7 @@ public class WebDAVHelperTest
public void canGetUrlPathPrefixFromServletPath()
{
// Path prefix not explicitly set on helper.
davHelper = new WebDAVHelper("", serviceRegistry, authService, tenantService);
davHelper.setUrlPathPrefix("");
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/before/the-servlet/folder/filename.txt");
// Servlet path will be used to determine path prefix.
request.setServletPath("/the-servlet");

View File

@@ -46,6 +46,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.model.filefolder.HiddenAspect;
import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.security.permissions.AccessDeniedException;
@@ -66,6 +68,8 @@ import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.FileFilterMode;
import org.alfresco.util.FileFilterMode.Client;
import org.alfresco.util.TempFileProvider;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -991,6 +995,38 @@ public abstract class WebDAVMethod
return ns.toString();
}
protected void setHidden(NodeRef nodeRef, boolean isHidden)
{
int mask = 0;
boolean allVisible = true;
Visibility webDavVisibility = isHidden ? Visibility.NotVisible : Visibility.Visible;
HiddenAspect hiddenAspect = m_davHelper.getHiddenAspect();
for (Client client : hiddenAspect.getClients())
{
Visibility clientVisibility = client == FileFilterMode.getClient() ? webDavVisibility : hiddenAspect
.getVisibility(client, nodeRef);
if (clientVisibility != Visibility.Visible)
{
allVisible = false;
}
mask |= hiddenAspect.getClientVisibilityMask(client, clientVisibility);
}
if (allVisible)
{
getNodeService().removeAspect(nodeRef, ContentModel.ASPECT_HIDDEN);
}
else
{
hiddenAspect.hideNode(nodeRef, mask);
}
}
protected boolean isHidden(NodeRef nodeRef)
{
return m_davHelper.getHiddenAspect().getVisibility(FileFilterMode.getClient(), nodeRef) != Visibility.Visible;
}
/**
* Checks if write operation can be performed on node.
*
@@ -1098,16 +1134,18 @@ public abstract class WebDAVMethod
}
else
{
// This particular node is not locked so it will not be part of the conditions
if (nodeLockToken == null)
{
return;
}
// Node has exclusive lock. Check if conditions contains lock token of the node
// If not throw exception
for (Condition condition : m_conditions)
{
if (nodeLockToken != null)
if (condition.getLockTokensMatch().contains(nodeLockToken))
{
if (condition.getLockTokensMatch().contains(nodeLockToken))
{
return;
}
return;
}
}
throw new WebDAVServerException(WebDAV.WEBDAV_SC_LOCKED);
@@ -1150,9 +1188,9 @@ public abstract class WebDAVMethod
// Checks If header conditions.
// Each condition can contain check of ETag and check of Lock token.
if (m_conditions == null)
if (m_conditions == null || nodeLockToken == null)
{
// No conditions were provided with "If" request header, so check successful
// No conditions were provided with the "If" request header, or this node isn't locked and will not be in the conditions thus the check is successful
return;
}

View File

@@ -41,7 +41,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.FileFilterMode;
@@ -310,8 +309,6 @@ public class WebDAVServlet extends HttpServlet
transactionService = serviceRegistry.getTransactionService();
tenantService = (TenantService) context.getBean("tenantService");
AuthenticationService authService = (AuthenticationService) context.getBean("authenticationService");
nodeService = (NodeService) context.getBean("NodeService");
searchService = (SearchService) context.getBean("SearchService");
namespaceService = (NamespaceService) context.getBean("NamespaceService");
@@ -321,7 +318,7 @@ public class WebDAVServlet extends HttpServlet
// Collaborator used by WebDAV methods to create activity posts.
activityPoster = new ActivityPosterImpl("WebDAV", activityService);
// Create the WebDAV helper
// Get the WebDAV helper
m_davHelper = (WebDAVHelper) context.getBean("webDAVHelper");
// Initialize the root node