mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged V3.4-BUG-FIX to HEAD
31682: Fix for ALF-9504 - Upload non-flash fallback fails Merged HEAD to V3.4-BUG-FIX 31065: Fixed ALF-10407 "Share HTML uploader broken in Swift" 31738: merged DEV to V3.4_BUG_FIX 31681 : ALF-7859 - Deployment fails for *.xml content with wcm-xml-metadata-extracter-context.xml enabled 31755: Fix for ALF-9257: merged in and optimised Belarus fix. 31775: Fixed ALF-10667: WCM - Validation issue with xf:switch web forms 31817: Spanish: Updates translations (based on: r31738) & adds new WCM translations. 31840: Fix for ALF-10282 - Web Browser freezes with large xml files Web form transformation 31843: ALF-9208 Performance issue, during load tests /share/page/user/user-sites is showing to be the most expensive. Modification to AuthorityDAOImpl.findAuthorities(...) to use childAuthorityCache when possible Big improvement to 'My Sites' 31850: Italian: Translation updates, inc. fix for: ALF-11293. 31867: Merged DEV/TEMPORARY to V3.4-BUG-FIX 31400: ALF-10764: PDF vs 1.5 cause crash jvm - PDFRenderer library has been updated from 2009-09-27 to 0.9.1 version to support PDF documents of 1.5 version 31906: ALF-9545: Adjust date picker for IE 31911: Merge PATCHES/V3.3.3 to V3.4-BUG-FIX (3.4.7) 31905: ALF-10309 CLONE -WebDAV - Cancelling "save as" upload will create 0 byte content - Run Timer as the original user - Run timer if there is a LOCK timeout (not run if not so not to break standard. MS Office uses a 3 minute timeout) - PUT method clears aspect BEFORE it starts processing the content, so that the Timer does not remove the node if the content is very large - Delete node faster (than the Timer) if the client issues an UNLOCK, having locked the node but not issued a PUT. - Lots of debug 31708: ALF-10309 CLONE -WebDAV - Cancelling "save as" upload will create 0 byte content 'runAsSystem' the 5 minute timer to remove LOCKED but not PUT WebDAV files 31698: ALF-10309 CLONE -WebDAV - Cancelling "save as" upload will create 0 byte content Added 5 minute timer to remove LOCKED but not PUT WebDAV files 31687: ALF-10309 CLONE -WebDAV - Cancelling "save as" upload will create 0 byte content Added missing sys:webdavNoContent aspect to system model. 31913: Merge PATCHES/V3.4.1 (3.4.1.22) to V3.4-BUG-FIX (3.4.7) 31876: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode Use a retrying non-propagating (new) transaction to get the licence key in order to avoid intermittent issues. 31929: Merged BRANCHES/DEV/BELARUS/V3.4-BUG-FIX-2011_11_09 to BRANCHES/DEV/V3.4-BUG-FIX 31903: ALF-9971: RM search doesn't work with NAME:any_text: Check for dublicate template of properties was added. Throws an exception if there is already an entry in the map entry. 31931: ALF_9678 Fixed null pointer issues in WorkflowManager methods 31938: Merged DEV to V3.4-BUG-FIX 31932: ALF-9566: hasMoreItems always false in CMIS query (Web Service binding) 1. PropertyFilter was fixed to be able to handle OpenCMIS Workbench. Unit test was updated. 2. hasMoreItems was adopted to indicate whether more itemsa are avliable in the repo based on maxItems and skipCount. Unit test was added. 3. CMISFolderTypeDefinition was fixed to be fileable according to 2.1.5.1 File-able Objects. 31965: German: Translation updates and additions based on EN r31738 31967: French: Translation updates and additions based on EN r31738 31969: Spanish: : Translation updates and additions based on EN r31738 31971: Italian: Translation updates and additions based on EN r31738 31972: Fix for patch 'alternatives': Alternative patch must have executed and not just been marked as successful 31973: Fixed ALF-11489: 'patch.sitesSpacePermissions' failed on upgrade 2.2.8 -> 3.4.6 - 'patch.sitesFolder' is an alternative to 'patch.sitesSpacePermissions' - Note: Requires rev 31972 for fix to PatchService use of alternatives 31994: ALF-11495 CLONE - Enterprise unlimited licenses still get invalidated turning the system into read-only mode - Replaced DescriptorDAORetryingInterceptor (add in the hotfix) with a RetryingTransactionInterceptor 31999: Change the low level CIFS packet reading code to read/process up to 4 requests per thread run. ALF-9540 Reduces thread blocking when the CIFS client uses overlapped I/O, and also keeps writes in their original sequence. 32037: Japanese: Translation update, new and modified strings based on EN r31738 32061: ALF-11376 Requesting PDFBox 1.6 be included in future service pack release. Upgrading pdfbox,fontbox,jempbox from 1.5.0 to 1.6.0 32074: ALF-11522 IMAP: Generic AlfrescoImapFolderException error is a bit misleading "Can't create folder - Permission denied" --> "Cannot perform action - permission denied" 32086: ALF-9971 RM search doesn't work with NAME:any_text - fix to test failure to do with upper case defaultFieldName finding nothing 32093: Merged BELARUS/V3.4-BUG-FIX-2011_10_13 to V3.4-BUG-FIX (3.4.7) Plus a little bit of refactoring to remove duplicate code 31490: ALF-9817: IE strips exe extension on download file when using download url with ticket parameter in code The "filename" part for "Content-Disposition" header in case of "attachment" for IE 32115: ALF-11569: Merged V3.3 to V3.4-BUG-FIX 32108: ALF-11571: Fix new deadlock in NIO CIFSRequestHandler - Needed to be able to get a thread safe estimate of the number of registered sessions without synchronizing on m_selector.keys() because a lock is held by the selector whilst waiting - Now the session count is maintained by the main thread, which is woken by anything wanting a session count. 32136: ALF-10412 Nonreducing 100% CPU Uploading Large Files to Share Site Document Library Reducing the priority of the async thread pool that is used to perform the transformations so that normal activity (and even garbage collection) is not interrupted by transformations. 32143: MERGED 2011_11_09 to V3.4-BUG-FIX 32133 - ALF-11193 Consumer role cannot Unscribe/subscribe the IMAP folders. 32137 32152: Merged BRANCHES/DEV/BELARUS/V3.4-BUG-FIX-2011_10_13 to BRANCHES/DEV/V3.4-BUG-FIX: 31731: ALF-6275: Discrepancy detected on archived pivot language with EditionService 32171: ALF-9638: Version2ServiceImpl now freezes aspect specific associations, in line with VersionServiceImpl 32191: Merged DEV to V3.4-BUG-FIX 32187: ALF-10884: A file renamed using the web UI still appears in a NFS mount but with NULL stats - Timestamp propogation in case of move - getPaths() call removed from the NodeMonitor 32192: Reversed out rev 32143: ALF-11193: Consumer role cannot Unscribe/subscribe the IMAP folders. - Patch is using SearchService - Patch doesn't transfer IMAP 'unsubscriptions' - Patch will not scale 32211: Merged V3.4 to V3.4-BUG-FIX 31914: ALF-10619: Not all container deletions were being honoured during indexing due to deletionsSinceFlushed processing - If container B is under container A with a secondary association, and A then B were deleted, then not all of Bs containers were getting masked out - only those in a subtree of A! - Now that delete events are fired on every affected node in a cascading delete, we can handle the nodes and containers on an individual basis 31915: ALF-10619: Prevent possible InvalidNodeRefException during reindexing - Handle in childRelationshipEvent() when comparing with 'path generation factor' 32322: Possible fix for: (ALF-11344) SORT clause in CMIS query (ORDER BY) drastically affects performance of search. - English based locales will sort as Java String comparison. 32327: ALF-11495: Merge V3.4.1 (3.4.1.23) to V3.4-BUG-FIX (3.4.8) 32326: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode MaxUserLicenseException class was not added to SVN in previous commit 32325: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode Remove RetryingTransactionInterceptor from around RepositoryDescriptorDAOImpl - not needed any more and caused extra exception if repo was r/o on boot 32324: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode Addition of message to say temporary problem has gone away 32323: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode Think I have found the reason for the vanishing licenses. License Descriptor can be accessed but the file in the content store cannot be read. Tidy up of code to remove TODO messages Addition of MaxUserLicenseException Additional code to handle possible temporary license outages and recovery Addition of more specific exception of invalid content store issue 32326: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode MaxUserLicenseException class was not added to SVN in previous commit 32288: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode Fix tests by still failing if we have not loaded a license yet 32259: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode Ignore exceptions from debug after RepositoryDescriptorDAOImpl Throwable 32252: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode Addition of logging and keep license live after error 32343: FIXED - issue ALF-11617: wma file type is mapped to 'video/x-ms-wma' mimetype instead of audio/x-ms-wma' Changed the type audio/x-ms-wma 32346: Fixed query use-case lookup of assoc namespace entity (i.e. should not lazily create) - Does not need merging to 4.0, which contains the fixes already 32349: Merged V3.3 to V3.4-BUG-FIX 32347: Prevent possible deadlock during subsystem syncing in a cluster 32352: ALF-11495: Merge V3.4.1 (3.4.1.23) to V3.4-BUG-FIX (3.4.8) PLEASE NOTE that ALF-11381 was also merged into V3.4-BUG-FIX in r32327 32350: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode Patched version of true license to log RunTimeExceptions and Errors from both ftp and non-ftp LicenseManager verify methods 32332: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode Cannot throw specific Exception for the file reader issue as returning null is required for FTL 32356: ALF-11495: Merge V3.4.1 (3.4.1.23) to V3.4-BUG-FIX (3.4.8) 32355: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode TrueLicense missing from classpath.unit.test.extension 32387: ALF-11617 Correct mimetype for WMA audio (with patch) 32395: ALF-11004 Workflow Interpreter can now handle transitions with spaces in the name when 'signal' is called. 32398: ALF-11078: Reinstate maxPermissionChecks logging from ALF-7237 32411: Fix for ALF-11344 SORT clause in CMIS query (ORDER BY) drastically affects performance of search. - use in memory sort rather than relying on the lucene field cache for result sets up to 1000 by default - this is configurable across all query languages (and per query via SearchParameters and QueryOptions) lucene.indexer.useInMemorySort=true lucene.indexer.maxRawResultSetSizeForInMemorySort=1000 32425: Fix for ALF-11344 SORT clause in CMIS query (ORDER BY) drastically affects performance of search. - fix for score sorting 32433: Merged V3.4 to V3.4-BUG-FIX 32432: ALF-11743: When RM is installed, admin does not have the appropriate permissions to perform any operations in Alfresco Explorer git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32477 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -66,6 +66,8 @@ public class DMDiscoveryServicePort extends DMAbstractServicePort implements Dis
|
||||
* Queries the repository for queryable object based on properties or an optional full-text string. Relationship objects are not queryable. Content-streams are not returned as
|
||||
* part of query
|
||||
*
|
||||
* ALF-9566 : hasMoreItems was changed to be confirmed with a section (2.2.1.1 Paging) of the specification.
|
||||
*
|
||||
* @param parameters query parameters
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
@@ -107,6 +109,8 @@ public class DMDiscoveryServicePort extends DMAbstractServicePort implements Dis
|
||||
maxItems = parameters.getMaxItems().getValue().intValue();
|
||||
}
|
||||
|
||||
// total number of items
|
||||
int numItems = resultSet.getLength();
|
||||
// for each row...
|
||||
int idx = 0;
|
||||
for (CMISResultSetRow row : resultSet)
|
||||
@@ -162,8 +166,9 @@ public class DMDiscoveryServicePort extends DMAbstractServicePort implements Dis
|
||||
response.getObjects().getObjects().add(object);
|
||||
idx++;
|
||||
}
|
||||
response.getObjects().setNumItems(BigInteger.valueOf(skipCount + resultSet.getLength()));
|
||||
response.getObjects().setHasMoreItems(resultSet.hasMore());
|
||||
response.getObjects().setNumItems(BigInteger.valueOf(numItems));
|
||||
boolean hasMoreItems = (maxItems != -1 ? (numItems - (skipCount + maxItems)) > 0 : false) || resultSet.hasMore();
|
||||
response.getObjects().setHasMoreItems(hasMoreItems);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@@ -56,9 +56,11 @@ public abstract class BaseCMISTest extends TestCase
|
||||
protected String repositoryId;
|
||||
protected String testFolderId;
|
||||
|
||||
protected ApplicationContext ctx;
|
||||
|
||||
public BaseCMISTest()
|
||||
{
|
||||
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(new String[]
|
||||
ctx = ApplicationContextHelper.getApplicationContext(new String[]
|
||||
{
|
||||
ApplicationContextHelper.CONFIG_LOCATIONS[0], "classpath:alfresco/web-services-application-context.xml"
|
||||
});
|
||||
|
182
source/java/org/alfresco/repo/cmis/ws/test/QueryPagingTest.java
Normal file
182
source/java/org/alfresco/repo/cmis/ws/test/QueryPagingTest.java
Normal file
@@ -0,0 +1,182 @@
|
||||
package org.alfresco.repo.cmis.ws.test;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.repo.cmis.ws.CmisContentStreamType;
|
||||
import org.alfresco.repo.cmis.ws.CmisException;
|
||||
import org.alfresco.repo.cmis.ws.CmisExtensionType;
|
||||
import org.alfresco.repo.cmis.ws.CmisObjectInFolderListType;
|
||||
import org.alfresco.repo.cmis.ws.CmisObjectInFolderType;
|
||||
import org.alfresco.repo.cmis.ws.CmisObjectType;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertiesType;
|
||||
import org.alfresco.repo.cmis.ws.CmisProperty;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertyId;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertyString;
|
||||
import org.alfresco.repo.cmis.ws.DiscoveryServicePort;
|
||||
import org.alfresco.repo.cmis.ws.EnumVersioningState;
|
||||
import org.alfresco.repo.cmis.ws.NavigationServicePort;
|
||||
import org.alfresco.repo.cmis.ws.ObjectFactory;
|
||||
import org.alfresco.repo.cmis.ws.Query;
|
||||
import org.alfresco.repo.cmis.ws.QueryResponse;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
|
||||
/**
|
||||
* The test of paging support of results of DMDiscoveryServicePort.query()
|
||||
*
|
||||
* @author Arseny Kovalchuk
|
||||
*/
|
||||
public class QueryPagingTest extends BaseCMISTest
|
||||
{
|
||||
private static final int NUMBER_OF_DOCUMENTS = 50;
|
||||
private static final String QUERY_DOCUMENTS_TEMPLATE = "select * from cmis:document d where in_folder('%1$s')";
|
||||
|
||||
private static final ObjectFactory OBJECT_FACTORY = new ObjectFactory();
|
||||
|
||||
private String queryDocuments;
|
||||
|
||||
protected DiscoveryServicePort discoveryServicePort;
|
||||
protected NavigationServicePort navigationServicePort;
|
||||
|
||||
public QueryPagingTest()
|
||||
{
|
||||
super();
|
||||
discoveryServicePort = (DiscoveryServicePort) ctx.getBean("dmDiscoveryService");
|
||||
navigationServicePort = (NavigationServicePort) ctx.getBean("dmNavigationService");
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
queryDocuments = String.format(QUERY_DOCUMENTS_TEMPLATE, testFolderId);
|
||||
//System.out.println(queryDocuments);
|
||||
}
|
||||
|
||||
/**
|
||||
* The main reason for this test is ALF-9566
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testPagingSupport() throws Exception
|
||||
{
|
||||
clearDocumentsInFolder(testFolderId);
|
||||
|
||||
createDocumentsInFolder(testFolderId, NUMBER_OF_DOCUMENTS);
|
||||
|
||||
// Select 10 of NUMBER_OF_DOCUMENTS, 0 documents to skip, so NUMBER_OF_DOCUMENTS - 10 still available
|
||||
int skipCount = 0;
|
||||
int maxItems = 10;
|
||||
QueryResponse response = discoveryServicePort.query(createQuery(maxItems, skipCount));
|
||||
assertEquals(NUMBER_OF_DOCUMENTS - skipCount, response.getObjects().getNumItems().intValue());
|
||||
assertEquals(maxItems, response.getObjects().getObjects().size());
|
||||
assertTrue(response.getObjects().isHasMoreItems());
|
||||
|
||||
// Select 10 of NUMBER_OF_DOCUMENTS, 10 documents to skip, so NUMBER_OF_DOCUMENTS - 10 - 10 still available
|
||||
skipCount = 10;
|
||||
maxItems = 10;
|
||||
response = discoveryServicePort.query(createQuery(maxItems, skipCount));
|
||||
assertEquals(NUMBER_OF_DOCUMENTS - skipCount, response.getObjects().getNumItems().intValue());
|
||||
assertEquals(maxItems, response.getObjects().getObjects().size());
|
||||
assertTrue(response.getObjects().isHasMoreItems());
|
||||
|
||||
// Select 10 of NUMBER_OF_DOCUMENTS, NUMBER_OF_DOCUMENTS - 10 to skip, so there are no docs available
|
||||
skipCount = NUMBER_OF_DOCUMENTS - 10;
|
||||
maxItems = 10;
|
||||
response = discoveryServicePort.query(createQuery(maxItems, skipCount));
|
||||
assertEquals(NUMBER_OF_DOCUMENTS - skipCount, response.getObjects().getNumItems().intValue());
|
||||
assertEquals(maxItems, response.getObjects().getObjects().size());
|
||||
assertFalse(response.getObjects().isHasMoreItems());
|
||||
|
||||
// Select NUMBER_OF_DOCUMENTS to select, 0 to skip, so, there are no docs available
|
||||
skipCount = 0;
|
||||
maxItems = NUMBER_OF_DOCUMENTS;
|
||||
response = discoveryServicePort.query(createQuery(maxItems, skipCount));
|
||||
assertEquals(NUMBER_OF_DOCUMENTS - skipCount, response.getObjects().getNumItems().intValue());
|
||||
assertEquals(maxItems, response.getObjects().getObjects().size());
|
||||
assertFalse(response.getObjects().isHasMoreItems());
|
||||
|
||||
clearDocumentsInFolder(testFolderId);
|
||||
}
|
||||
|
||||
protected void createDocumentsInFolder(String folderId, int docsCount) throws Exception
|
||||
{
|
||||
for (int i = 0; i < NUMBER_OF_DOCUMENTS; i++)
|
||||
{
|
||||
String docName = "Test Document " + i + ".txt";
|
||||
//System.out.println("Creating " + docName);
|
||||
createDocument(docName, folderId);
|
||||
}
|
||||
}
|
||||
|
||||
protected void clearDocumentsInFolder(String folderId) throws CmisException
|
||||
{
|
||||
CmisObjectInFolderListType result = navigationServicePort.getChildren(repositoryId, testFolderId, "*", null, false, null, null, false, BigInteger.valueOf(-1),
|
||||
BigInteger.ZERO, null);
|
||||
if (!result.getObjects().isEmpty())
|
||||
{
|
||||
for(CmisObjectInFolderType obj : result.getObjects())
|
||||
{
|
||||
String documentId = getObjectId(obj.getObject());
|
||||
//System.out.println("Deleting document with ID:" + documentId);
|
||||
objectServicePort.deleteObject(repositoryId, documentId, true, new Holder<CmisExtensionType>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String getObjectId(CmisObjectType object)
|
||||
{
|
||||
CmisPropertiesType propertiesType = object.getProperties();
|
||||
for(CmisProperty property : propertiesType.getProperty())
|
||||
{
|
||||
if ((property instanceof CmisPropertyId) && CMISDictionaryModel.PROP_OBJECT_ID.equals(property.getPropertyDefinitionId()))
|
||||
{
|
||||
return ((CmisPropertyId) property).getValue().iterator().next();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String createDocument(String name, String parentFolderId) throws Exception
|
||||
{
|
||||
String content = "This is a test content";
|
||||
CmisPropertiesType properties = new CmisPropertiesType();
|
||||
List<CmisProperty> propertiesList = properties.getProperty();
|
||||
CmisPropertyString cmisProperty = new CmisPropertyString();
|
||||
cmisProperty.setPropertyDefinitionId(CMISDictionaryModel.PROP_NAME);
|
||||
cmisProperty.getValue().add(name);
|
||||
CmisPropertyId idProperty = new CmisPropertyId();
|
||||
idProperty.setPropertyDefinitionId(CMISDictionaryModel.PROP_OBJECT_TYPE_ID);
|
||||
idProperty.getValue().add(CMISDictionaryModel.DOCUMENT_TYPE_ID.getId());
|
||||
|
||||
propertiesList.add(cmisProperty);
|
||||
propertiesList.add(idProperty);
|
||||
|
||||
CmisContentStreamType cmisStream = new CmisContentStreamType();
|
||||
cmisStream.setFilename(name);
|
||||
cmisStream.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
|
||||
DataHandler dataHandler = new DataHandler(content, MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
cmisStream.setStream(dataHandler);
|
||||
|
||||
Holder<CmisExtensionType> extensions = new Holder<CmisExtensionType>();
|
||||
Holder<String> idHolder = new Holder<String>();
|
||||
objectServicePort.createDocument(repositoryId, properties, parentFolderId, cmisStream, EnumVersioningState.MAJOR, null, null, null, extensions, idHolder);
|
||||
return idHolder.value;
|
||||
}
|
||||
|
||||
private Query createQuery(int maxItems, int skipCount)
|
||||
{
|
||||
Query parameters = new Query();
|
||||
parameters.setRepositoryId(repositoryId);
|
||||
parameters.setStatement(queryDocuments);
|
||||
parameters.setSkipCount(OBJECT_FACTORY.createQuerySkipCount(BigInteger.valueOf(skipCount)));
|
||||
parameters.setMaxItems(OBJECT_FACTORY.createQueryMaxItems(BigInteger.valueOf(maxItems)));
|
||||
parameters.setIncludeAllowableActions(OBJECT_FACTORY.createQueryIncludeAllowableActions(Boolean.FALSE));
|
||||
parameters.setSearchAllVersions(OBJECT_FACTORY.createQuerySearchAllVersions(Boolean.FALSE));
|
||||
return parameters;
|
||||
}
|
||||
|
||||
}
|
@@ -21,17 +21,23 @@ package org.alfresco.repo.webdav;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WebDAVModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.lock.LockType;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileFolderUtil;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
@@ -48,6 +54,8 @@ public class LockMethod extends WebDAVMethod
|
||||
{
|
||||
public static final String EMPTY_NS = "";
|
||||
|
||||
private static Timer timer = new Timer(true);
|
||||
|
||||
protected int m_timeoutDuration = WebDAV.TIMEOUT_INFINITY;
|
||||
|
||||
protected LockInfo lockInfo = new LockInfo();
|
||||
@@ -206,10 +214,10 @@ public class LockMethod extends WebDAVMethod
|
||||
protected void executeImpl() throws WebDAVServerException, Exception
|
||||
{
|
||||
FileFolderService fileFolderService = getFileFolderService();
|
||||
String path = getPath();
|
||||
final String path = getPath();
|
||||
NodeRef rootNodeRef = getRootNodeRef();
|
||||
// Get the active user
|
||||
String userName = getDAVHelper().getAuthenticationService().getCurrentUserName();
|
||||
final String userName = getDAVHelper().getAuthenticationService().getCurrentUserName();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -258,9 +266,66 @@ public class LockMethod extends WebDAVMethod
|
||||
// ALF-10309 fix, mark created node with webdavNoContent aspect, we assume that save operation
|
||||
// is performed by client, webdavNoContent aspect normally removed in put method unless there
|
||||
// is a cancel before the PUT request takes place
|
||||
if (!getNodeService().hasAspect(lockNodeInfo.getNodeRef(), ContentModel.ASPECT_WEBDAV_NO_CONTENT))
|
||||
int lockTimeout = getLockTimeout();
|
||||
if (lockTimeout > 0 &&
|
||||
!getNodeService().hasAspect(lockNodeInfo.getNodeRef(), ContentModel.ASPECT_WEBDAV_NO_CONTENT))
|
||||
{
|
||||
getNodeService().addAspect(lockNodeInfo.getNodeRef(), ContentModel.ASPECT_WEBDAV_NO_CONTENT, null);
|
||||
final NodeRef nodeRef = lockNodeInfo.getNodeRef();
|
||||
getNodeService().addAspect(nodeRef, ContentModel.ASPECT_WEBDAV_NO_CONTENT, null);
|
||||
|
||||
// Remove node after the timeout (MS Office 2003 requests 3 minutes) if the PUT or UNLOCK has not taken place
|
||||
timer.schedule(new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// run as current user
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
if (getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WEBDAV_NO_CONTENT))
|
||||
{
|
||||
getTransactionService().getRetryingTransactionHelper().doInTransaction(
|
||||
new RetryingTransactionCallback<String>()
|
||||
{
|
||||
public String execute() throws Throwable
|
||||
{
|
||||
getNodeService().removeAspect(nodeRef, ContentModel.ASPECT_WEBDAV_NO_CONTENT);
|
||||
getNodeService().deleteNode(nodeRef);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Timer DELETE " + path);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, false, true);
|
||||
}
|
||||
else if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Timer IGNORE " + path);
|
||||
}
|
||||
}
|
||||
catch (InvalidNodeRefException e)
|
||||
{
|
||||
// Might get this if the node is deleted. If so just ignore.
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Timer DOES NOT EXIST " + path);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, userName);
|
||||
}
|
||||
}, lockTimeout*1000);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Timer START in " + lockTimeout + " seconds "+ path);
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
|
@@ -19,9 +19,6 @@
|
||||
package org.alfresco.repo.webdav;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -37,7 +34,6 @@ import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
|
||||
/**
|
||||
@@ -51,6 +47,10 @@ public class PutMethod extends WebDAVMethod
|
||||
private String m_strLockToken = null;
|
||||
private String m_strContentType = null;
|
||||
private boolean m_expectHeaderPresent = false;
|
||||
|
||||
// Indicates if a zero byte node was created by a LOCK call.
|
||||
// Try to delete the node if the PUT fails
|
||||
private boolean noContent = false;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -80,23 +80,74 @@ public class PutMethod extends WebDAVMethod
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the request body
|
||||
* Clears the aspect added by a LOCK request for a new file, so
|
||||
* that the Timer started by the LOCK request will not remove the
|
||||
* node now that the PUT request has been received. This is needed
|
||||
* for large content.
|
||||
*
|
||||
* @exception WebDAVServerException
|
||||
*/
|
||||
protected void parseRequestBody() throws WebDAVServerException
|
||||
{
|
||||
// Nothing to do in this method, the body contains
|
||||
// the content it will be dealt with later
|
||||
// Nothing is done with the body by this method. The body contains
|
||||
// the content it will be dealt with later.
|
||||
|
||||
// This method is called ONCE just before the FIRST call to executeImpl,
|
||||
// which is in a retrying transaction so may be called many times.
|
||||
|
||||
// Although this method is called just before the first executeImpl,
|
||||
// it is possible that the Thread could be interrupted before the first call
|
||||
// or between calls. However the chances are low and the consequence
|
||||
// (leaving a zero byte file) is minor.
|
||||
|
||||
noContent = getTransactionService().getRetryingTransactionHelper().doInTransaction(
|
||||
new RetryingTransactionCallback<Boolean>()
|
||||
{
|
||||
public Boolean execute() throws Throwable
|
||||
{
|
||||
FileInfo contentNodeInfo = null;
|
||||
try
|
||||
{
|
||||
contentNodeInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), getPath(), getServletPath());
|
||||
checkNode(contentNodeInfo);
|
||||
final NodeRef nodeRef = contentNodeInfo.getNodeRef();
|
||||
if (getNodeService().hasAspect(contentNodeInfo.getNodeRef(), ContentModel.ASPECT_WEBDAV_NO_CONTENT))
|
||||
{
|
||||
getNodeService().removeAspect(nodeRef, ContentModel.ASPECT_WEBDAV_NO_CONTENT);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
String path = getPath();
|
||||
logger.debug("Put Timer DISABLE " + path);
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
// Does not exist, so there will be no aspect.
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exceute the WebDAV request
|
||||
* Execute the WebDAV request
|
||||
*
|
||||
* @exception WebDAVServerException
|
||||
*/
|
||||
protected void executeImpl() throws WebDAVServerException, Exception
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
String path = getPath();
|
||||
String userName = getDAVHelper().getAuthenticationService().getCurrentUserName();
|
||||
logger.debug("Put node: \n" +
|
||||
" user: " + userName + "\n" +
|
||||
" path: " + path + "\n" +
|
||||
"noContent: " + noContent);
|
||||
}
|
||||
|
||||
FileFolderService fileFolderService = getFileFolderService();
|
||||
|
||||
// Get the status for the request path
|
||||
@@ -170,7 +221,6 @@ public class PutMethod extends WebDAVMethod
|
||||
|
||||
// Write the new data to the content node
|
||||
writer.putContent(is);
|
||||
|
||||
// Ask for the document metadata to be extracted
|
||||
Action extract = getActionService().createAction(ContentMetadataExtracter.EXECUTOR_NAME);
|
||||
if(extract != null)
|
||||
@@ -180,20 +230,15 @@ public class PutMethod extends WebDAVMethod
|
||||
}
|
||||
|
||||
|
||||
// write content was successful -> remove noContent aspect
|
||||
if (getNodeService().hasAspect(contentNodeInfo.getNodeRef(), ContentModel.ASPECT_WEBDAV_NO_CONTENT))
|
||||
{
|
||||
getNodeService().removeAspect(contentNodeInfo.getNodeRef(), ContentModel.ASPECT_WEBDAV_NO_CONTENT);
|
||||
}
|
||||
|
||||
// Set the response status, depending if the node existed or not
|
||||
m_response.setStatus(created ? HttpServletResponse.SC_CREATED : HttpServletResponse.SC_NO_CONTENT);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// check if the node was marked with noContent aspect previously by lock method
|
||||
if (RetryingTransactionHelper.extractRetryCause(e) == null
|
||||
&& getNodeService().hasAspect(contentNodeInfo.getNodeRef(), ContentModel.ASPECT_WEBDAV_NO_CONTENT))
|
||||
// check if the node was marked with noContent aspect previously by lock method AND
|
||||
// we are about to give up
|
||||
if (noContent && RetryingTransactionHelper.extractRetryCause(e) == null)
|
||||
{
|
||||
// remove the 0 bytes content if save operation failed or was cancelled
|
||||
final NodeRef nodeRef = contentNodeInfo.getNodeRef();
|
||||
@@ -202,8 +247,11 @@ public class PutMethod extends WebDAVMethod
|
||||
{
|
||||
public String execute() throws Throwable
|
||||
{
|
||||
getNodeService().removeAspect(nodeRef, ContentModel.ASPECT_WEBDAV_NO_CONTENT);
|
||||
getNodeService().deleteNode(nodeRef);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Put failed. DELETE " + getPath());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, false, true);
|
||||
|
@@ -28,6 +28,7 @@ import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.lock.LockStatus;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -111,7 +112,7 @@ public class UnlockMethod extends WebDAVMethod
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Lock node; path=" + getPath() + ", token=" + getLockToken());
|
||||
logger.debug("Unlock node; path=" + getPath() + ", token=" + getLockToken());
|
||||
}
|
||||
|
||||
FileInfo lockNodeInfo = null;
|
||||
@@ -138,22 +139,25 @@ public class UnlockMethod extends WebDAVMethod
|
||||
// String nodeId = lockInfo[0];
|
||||
// String userName = lockInfo[1];
|
||||
|
||||
LockStatus lockSts = lockService.getLockStatus(lockNodeInfo.getNodeRef());
|
||||
NodeRef nodeRef = lockNodeInfo.getNodeRef();
|
||||
LockStatus lockSts = lockService.getLockStatus(nodeRef);
|
||||
if (lockSts == LockStatus.LOCK_OWNER)
|
||||
{
|
||||
lockService.unlock(lockNodeInfo.getNodeRef());
|
||||
nodeService.removeProperty(lockNodeInfo.getNodeRef(), WebDAVModel.PROP_OPAQUE_LOCK_TOKEN);
|
||||
nodeService.removeProperty(lockNodeInfo.getNodeRef(), WebDAVModel.PROP_LOCK_DEPTH);
|
||||
nodeService.removeProperty(lockNodeInfo.getNodeRef(), WebDAVModel.PROP_LOCK_SCOPE);
|
||||
if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
|
||||
lockService.unlock(nodeRef);
|
||||
nodeService.removeProperty(nodeRef, WebDAVModel.PROP_OPAQUE_LOCK_TOKEN);
|
||||
nodeService.removeProperty(nodeRef, WebDAVModel.PROP_LOCK_DEPTH);
|
||||
nodeService.removeProperty(nodeRef, WebDAVModel.PROP_LOCK_SCOPE);
|
||||
|
||||
// Return the cm:lockable aspect to working copy (ALF-4479, ALF-7079)
|
||||
if (nodeService.hasAspect(lockNodeInfo.getNodeRef(), ContentModel.ASPECT_WORKING_COPY))
|
||||
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
|
||||
{
|
||||
nodeService.addAspect(lockNodeInfo.getNodeRef(), ContentModel.ASPECT_LOCKABLE, null);
|
||||
nodeService.addAspect(nodeRef, ContentModel.ASPECT_LOCKABLE, null);
|
||||
}
|
||||
|
||||
// Indicate that the unlock was successful
|
||||
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
|
||||
removeNoContentAspect(nodeRef);
|
||||
|
||||
// DEBUG
|
||||
if (logger.isDebugEnabled())
|
||||
@@ -163,7 +167,7 @@ public class UnlockMethod extends WebDAVMethod
|
||||
}
|
||||
else if (lockSts == LockStatus.NO_LOCK)
|
||||
{
|
||||
String sharedLocks = (String) nodeService.getProperty(lockNodeInfo.getNodeRef(), WebDAVModel.PROP_SHARED_LOCK_TOKENS);
|
||||
String sharedLocks = (String) nodeService.getProperty(nodeRef, WebDAVModel.PROP_SHARED_LOCK_TOKENS);
|
||||
if (sharedLocks != null)
|
||||
{
|
||||
Set<String> locks = LockInfo.parseSharedLockTokens(sharedLocks);
|
||||
@@ -171,10 +175,11 @@ public class UnlockMethod extends WebDAVMethod
|
||||
if (locks != null && locks.contains(m_strLockToken))
|
||||
{
|
||||
locks.remove(m_strLockToken);
|
||||
nodeService.setProperty(lockNodeInfo.getNodeRef(), WebDAVModel.PROP_SHARED_LOCK_TOKENS, LockInfo.makeSharedLockTokensString(locks));
|
||||
nodeService.setProperty(nodeRef, WebDAVModel.PROP_SHARED_LOCK_TOKENS, LockInfo.makeSharedLockTokensString(locks));
|
||||
|
||||
// Indicate that the unlock was successful
|
||||
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
|
||||
removeNoContentAspect(nodeRef);
|
||||
|
||||
// DEBUG
|
||||
if (logger.isDebugEnabled())
|
||||
@@ -185,15 +190,13 @@ public class UnlockMethod extends WebDAVMethod
|
||||
}
|
||||
else
|
||||
{
|
||||
// DEBUG
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Unlock token=" + getLockToken() + " Not locked");
|
||||
// DEBUG
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Unlock token=" + getLockToken() + " Not locked");
|
||||
|
||||
// Node is not locked
|
||||
throw new WebDAVServerException(HttpServletResponse.SC_PRECONDITION_FAILED);
|
||||
}
|
||||
|
||||
|
||||
// Node is not locked
|
||||
throw new WebDAVServerException(HttpServletResponse.SC_PRECONDITION_FAILED);
|
||||
}
|
||||
}
|
||||
else if (lockSts == LockStatus.LOCKED)
|
||||
{
|
||||
@@ -209,9 +212,30 @@ public class UnlockMethod extends WebDAVMethod
|
||||
// DEBUG
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Unlock token=" + getLockToken() + " Lock expired");
|
||||
|
||||
|
||||
// Return a success status
|
||||
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
|
||||
removeNoContentAspect(nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
// This method removes a new zero byte node that has been locked, where the
|
||||
// PUT has not taken place but the client has issued an UNLOCK. The Timer
|
||||
// started in the LOCK will delete the node, but this is faster.
|
||||
// I have seen it with MS Office 2003 Excel. Almost impossible to reproduce.
|
||||
// Think Excel responds to a 'kill' request between the LOCK and PUT requests
|
||||
// and tries to tidy down as it exits.
|
||||
private void removeNoContentAspect(NodeRef nodeRef)
|
||||
{
|
||||
if (getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WEBDAV_NO_CONTENT))
|
||||
{
|
||||
getNodeService().removeAspect(nodeRef, ContentModel.ASPECT_WEBDAV_NO_CONTENT);
|
||||
getNodeService().deleteNode(nodeRef);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Unlock Timer DISABLE and DELETE " + getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user