mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +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:
@@ -112,7 +112,7 @@ public class EditionServiceImpl implements EditionService
|
||||
}
|
||||
|
||||
// get the properties to add to the edition history
|
||||
addPropertiesToVersion(versionProperties, mlContainerToVersion);
|
||||
addPropertiesToVersion(versionProperties, startingTranslationNodeRef);
|
||||
|
||||
// Version the container and its translations
|
||||
versionService.createVersion(mlContainerToVersion, versionProperties, true);
|
||||
|
@@ -20,13 +20,18 @@ package org.alfresco.repo.model.ml.tools;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.version.VersionModel;
|
||||
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.version.Version;
|
||||
import org.alfresco.service.cmr.version.VersionHistory;
|
||||
@@ -44,6 +49,15 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
|
||||
private static String CHINESE_CONTENT = "CHINESE_CONTENT";
|
||||
private static String JAPANESE_CONTENT = "JAPANESE_CONTENT";
|
||||
|
||||
private ContentService contentService;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
contentService = serviceRegistry.getContentService();
|
||||
}
|
||||
|
||||
public void testAutoEdition() throws Exception
|
||||
{
|
||||
// create a mlContainer with some content
|
||||
@@ -161,6 +175,92 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
|
||||
public void testReadVersionedProperties() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//ALF-6275
|
||||
public void testEditionServiceWithContent()
|
||||
{
|
||||
// create a mlContainer with some content
|
||||
NodeRef mlContainerNodeRef = createMLContainerWithContent("0.1");
|
||||
// get the french translation
|
||||
NodeRef frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef,
|
||||
Locale.FRENCH);
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
// create a new edition starting from the french translation
|
||||
NodeRef newStartingPoint = editionService.createEdition(frenchContentNodeRef, null);
|
||||
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
|
||||
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.2" + "-" + "0.2");
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.2" + "-" + "0.3");
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.2" + "-" + "0.4");
|
||||
// checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
|
||||
|
||||
newStartingPoint = editionService.createEdition(frenchContentNodeRef, null);
|
||||
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
|
||||
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.3" + "-" + "0.2");
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.3" + "-" + "0.3");
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
NodeRef chineseContentNodeRef = createContent(CHINESE_CONTENT + "-" + Locale.CHINESE + "-" + "0.3" + "-0.1");
|
||||
multilingualContentService.addTranslation(chineseContentNodeRef, mlContainerNodeRef, Locale.CHINESE);
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
NodeRef japaneseContentNodeRef = createContent(JAPANESE_CONTENT + "-" + Locale.JAPANESE + "-" + "0.3" + "-0.1");
|
||||
multilingualContentService.addTranslation(japaneseContentNodeRef, mlContainerNodeRef, Locale.JAPANESE);
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
|
||||
japaneseContentNodeRef = multilingualContentService
|
||||
.getTranslationForLocale(mlContainerNodeRef, Locale.JAPANESE);
|
||||
japaneseContentNodeRef = editionService.createEdition(japaneseContentNodeRef, null);
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
japaneseContentNodeRef = multilingualContentService
|
||||
.getTranslationForLocale(mlContainerNodeRef, Locale.JAPANESE);
|
||||
modifyContent(japaneseContentNodeRef, JAPANESE_CONTENT + "-" + Locale.JAPANESE + "-" + "0.4" + "-0.2");
|
||||
chineseContentNodeRef = createContent(CHINESE_CONTENT + "-" + Locale.CHINESE + "-" + "0.4" + "-0.1");
|
||||
|
||||
multilingualContentService.addTranslation(chineseContentNodeRef, mlContainerNodeRef, Locale.CHINESE);
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
frenchContentNodeRef = createContent(FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.4" + "-0.1");
|
||||
multilingualContentService.addTranslation(frenchContentNodeRef, mlContainerNodeRef, Locale.FRENCH);
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
|
||||
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
|
||||
newStartingPoint = editionService.createEdition(frenchContentNodeRef, null);
|
||||
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
|
||||
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "0.5" + "-" + "0.2");
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
|
||||
|
||||
japaneseContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.JAPANESE);
|
||||
HashMap<String, Serializable> versionProperties = new HashMap<String, Serializable>();
|
||||
versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR);
|
||||
japaneseContentNodeRef = editionService.createEdition(japaneseContentNodeRef, versionProperties);
|
||||
|
||||
Collection<Version> editions = editionService.getEditions(mlContainerNodeRef).getAllVersions();
|
||||
Version secondEdition = editions.iterator().next();
|
||||
// Ensure that the version label is 2.0
|
||||
assertTrue("The edition label would be 2.0 and not " + secondEdition.getVersionLabel(), secondEdition
|
||||
.getVersionLabel().equals("1.0"));
|
||||
frenchContentNodeRef = createContent(FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.0" + "-0.1");
|
||||
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "1.0" + "-" + "0.2");
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
|
||||
frenchContentNodeRef = multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH);
|
||||
|
||||
versionProperties = new HashMap<String, Serializable>();
|
||||
versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR);
|
||||
frenchContentNodeRef = editionService.createEdition(frenchContentNodeRef, versionProperties);
|
||||
|
||||
editions = editionService.getEditions(mlContainerNodeRef).getAllVersions();
|
||||
secondEdition = editions.iterator().next();
|
||||
// Ensure that the version label is 2.0
|
||||
assertTrue("The edition label would be 3.0 and not " + secondEdition.getVersionLabel(), secondEdition
|
||||
.getVersionLabel().equals("2.0"));
|
||||
modifyContent(frenchContentNodeRef, FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + "2.0" + "-" + "0.2");
|
||||
checkContentVersionValuesForEditions(mlContainerNodeRef);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void checkFirstVersion(NodeRef mlContainerNodeRef)
|
||||
@@ -200,4 +300,280 @@ public class EditionServiceImplTest extends AbstractMultilingualTestCases
|
||||
|
||||
return multilingualContentService.getTranslationContainer(chineseContentNodeRef);
|
||||
}
|
||||
|
||||
private void checkContentVersionValuesForEditions(NodeRef mlContainerNodeRef)
|
||||
{
|
||||
// the convention applied for this test is that the content MUST end up with
|
||||
// _LOCALE_EDITION-VERION_INDIVIDUAL-VERSION
|
||||
// get the edition list of edition
|
||||
VersionHistory editionHistory = editionService.getEditions(mlContainerNodeRef);
|
||||
|
||||
// Ensure that the first edition of the mlContainer is created
|
||||
assertNotNull("The edition history can't be null", editionHistory);
|
||||
// Ensure that it contains only one version
|
||||
assertTrue("The edition history must contain only one edition", editionHistory.getAllVersions().size() >= 1);
|
||||
|
||||
// iterate on editions
|
||||
for (Version editionVersion : editionHistory.getAllVersions())
|
||||
{
|
||||
// getting the edition label
|
||||
String editionLabel = editionVersion.getVersionLabel();
|
||||
// check if it is the head version
|
||||
if (editionHistory.getHeadVersion() == editionVersion)
|
||||
{
|
||||
// this is the living edition
|
||||
System.out.println("Head version edition:" + editionLabel);
|
||||
// dump content of head edition
|
||||
Map<Locale, NodeRef> translations = multilingualContentService.getTranslations(mlContainerNodeRef);
|
||||
Locale pivotLocale = (Locale) nodeService.getProperty(mlContainerNodeRef, ContentModel.PROP_LOCALE);
|
||||
Set<Locale> keySet = translations.keySet();
|
||||
for (Locale locale : keySet)
|
||||
{
|
||||
NodeRef translatedNode = translations.get(locale);
|
||||
// get content as string and compare
|
||||
ContentReader reader = contentService.getReader(translatedNode, ContentModel.PROP_CONTENT);
|
||||
String liveContent = reader.getContentString();
|
||||
Triplet parsedTriplet = new Triplet(liveContent);
|
||||
System.out.println("Content:" + liveContent);
|
||||
|
||||
// get all the version of current translation
|
||||
VersionHistory versionHistory = versionService.getVersionHistory(translatedNode);
|
||||
for (Version version : versionHistory.getAllVersions())
|
||||
{
|
||||
NodeRef frozenNodeRef = version.getFrozenStateNodeRef();
|
||||
String versionLabel = version.getVersionLabel();
|
||||
Locale versionLocale = (Locale) nodeService
|
||||
.getProperty(frozenNodeRef, ContentModel.PROP_LOCALE);
|
||||
// get content as string and compare
|
||||
reader = contentService.getReader(frozenNodeRef, ContentModel.PROP_CONTENT);
|
||||
String versionnedContent = reader.getContentString();
|
||||
System.out.println("Individual version " + versionLabel + ":" + versionnedContent);
|
||||
if (versionService.getCurrentVersion(translatedNode).getFrozenStateNodeRef().equals(
|
||||
version.getFrozenStateNodeRef()))
|
||||
{
|
||||
// this is the head version of the translation therefore content should be equal
|
||||
assertTrue(
|
||||
"The content in head version should be equal to the content of the translation:",
|
||||
versionnedContent.equals(liveContent));
|
||||
}
|
||||
// checking if content respects conventions XXX*locale*edition_version_*document_version
|
||||
// the exception should be the version used to start the new edition with
|
||||
// exception exist for root version because root version can be the first created
|
||||
// and if is the pivot language then its content is a copy of the previous edition.
|
||||
// This breaks the conventions and other checks must be done
|
||||
if ((versionHistory.getRootVersion().getFrozenStateNodeRef().equals(version
|
||||
.getFrozenStateNodeRef()))
|
||||
&& (pivotLocale.equals(versionLocale)))
|
||||
{
|
||||
System.out.println("Some special on live version has to be done:" + versionnedContent);
|
||||
// get previous edition
|
||||
Version previousEditionVersion = editionHistory.getPredecessor(editionVersion);
|
||||
|
||||
if (previousEditionVersion != null)
|
||||
{
|
||||
String previousEditionLabel = previousEditionVersion.getVersionLabel();
|
||||
System.out.println("Current edition Label:" + editionLabel + " Previous edition label:"
|
||||
+ previousEditionLabel);
|
||||
List<VersionHistory> versionTranslations = editionService
|
||||
.getVersionedTranslations(previousEditionVersion);
|
||||
// for all languages iterate to find the corresponding language
|
||||
for (VersionHistory versionTranslation : versionTranslations)
|
||||
{
|
||||
// most recent first
|
||||
Version newestVersion = versionTranslation.getHeadVersion();
|
||||
NodeRef newestVersionFrozenNodeRef = newestVersion.getFrozenStateNodeRef();
|
||||
String newestVersionVersionLabel = newestVersion.getVersionLabel();
|
||||
ContentReader readerContentWeStartedWith = contentService.getReader(
|
||||
newestVersionFrozenNodeRef, ContentModel.PROP_CONTENT);
|
||||
Locale oldestVersionLocale = (Locale) nodeService.getProperty(
|
||||
newestVersionFrozenNodeRef, ContentModel.PROP_LOCALE);
|
||||
String contentWeStartedWith = readerContentWeStartedWith.getContentString();
|
||||
System.out.println("CONTENT:" + contentWeStartedWith);
|
||||
if (versionLocale.equals(oldestVersionLocale))
|
||||
{
|
||||
// content should match
|
||||
assertTrue(
|
||||
"The content in head version should be equal to the content we started with:",
|
||||
contentWeStartedWith.equals(versionnedContent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// it is not a root version therefore it should respect the conventions
|
||||
Triplet testTriplet = new Triplet(versionnedContent);
|
||||
assertTrue(testTriplet.locale.equals(versionLocale.toString()));
|
||||
assertTrue(testTriplet.edition.equals(editionLabel));
|
||||
assertTrue(testTriplet.version.equals(versionLabel));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// get pivot language of the current versionned edition
|
||||
// This is not the current/head edition
|
||||
Version nextEditionVersion = editionHistory.getSuccessors(editionVersion).iterator().next();
|
||||
|
||||
//get Next verion label
|
||||
String nextEditionLabel = nextEditionVersion.getVersionLabel();
|
||||
System.out.println("Edition:" + editionLabel + " Next edition label:" + nextEditionLabel);
|
||||
// get the translations of the version
|
||||
List<VersionHistory> versionTranslations = editionService.getVersionedTranslations(editionVersion);
|
||||
// iterate on versionTranslations (all languages)
|
||||
|
||||
//strange that we have to go to the next edition to find the current pivot language.
|
||||
//maybe there is a reason for that but not logical logical
|
||||
dumpFrozenMetaData(editionVersion);
|
||||
Locale editionPivotlanguage = (Locale) (editionService.getVersionedMetadatas(editionVersion)
|
||||
.get(ContentModel.PROP_LOCALE));
|
||||
System.out.println("Edition:" + editionLabel + " Previous pivot language:" + editionPivotlanguage + " Current pivot language:" + editionPivotlanguage);
|
||||
for (VersionHistory versionTranslation : versionTranslations)
|
||||
{
|
||||
Collection<Version> versions = versionTranslation.getAllVersions();
|
||||
// for a language, iterate on all versions
|
||||
for (Version version : versions)
|
||||
{
|
||||
NodeRef frozenNodeRef = version.getFrozenStateNodeRef();
|
||||
String versionLabel = version.getVersionLabel();
|
||||
// get content language
|
||||
Locale currentVersionLocale = (Locale) nodeService.getProperty(frozenNodeRef,
|
||||
ContentModel.PROP_LOCALE);
|
||||
System.out.println("Current version locale:" + currentVersionLocale
|
||||
+ " Previous edition locale:" + editionPivotlanguage);
|
||||
// get content as string and compare
|
||||
ContentReader reader = contentService.getReader(frozenNodeRef, ContentModel.PROP_CONTENT);
|
||||
String content = reader.getContentString();
|
||||
System.out.println("Content:" + content);
|
||||
// checking content respects conventions XXX*locale*edition_version_*document_version
|
||||
// the exception should be the version used to start the new edition with
|
||||
Version initialVersion = versionTranslation.getRootVersion();
|
||||
if (initialVersion.equals(version) && currentVersionLocale.equals(editionPivotlanguage))
|
||||
{
|
||||
System.out.println("Some special test has to be done:" + content);
|
||||
Version previousEditionVersion = editionHistory.getPredecessor(editionVersion);
|
||||
|
||||
if (previousEditionVersion != null)
|
||||
{
|
||||
String previousEditionLabel = previousEditionVersion.getVersionLabel();
|
||||
System.out.println("Current edition Label:" + editionLabel + " Previous edition label:"
|
||||
+ previousEditionLabel);
|
||||
List<VersionHistory> versionTranslations2 = editionService
|
||||
.getVersionedTranslations(previousEditionVersion);
|
||||
// for all languages iterate to find the corresponding language
|
||||
for (VersionHistory versionTranslation2 : versionTranslations2)
|
||||
{
|
||||
// most recent first
|
||||
Version newestVersion = versionTranslation2.getHeadVersion();
|
||||
NodeRef newestVersionFrozenNodeRef = newestVersion.getFrozenStateNodeRef();
|
||||
String newestVersionVersionLabel = newestVersion.getVersionLabel();
|
||||
ContentReader readerContentWeStartedWith = contentService.getReader(
|
||||
newestVersionFrozenNodeRef, ContentModel.PROP_CONTENT);
|
||||
Locale oldestVersionLocale = (Locale) nodeService.getProperty(
|
||||
newestVersionFrozenNodeRef, ContentModel.PROP_LOCALE);
|
||||
String contentWeStartedWith = readerContentWeStartedWith.getContentString();
|
||||
System.out.println("CONTENT:" + contentWeStartedWith);
|
||||
if (currentVersionLocale.equals(oldestVersionLocale))
|
||||
{
|
||||
// content should match
|
||||
assertTrue(
|
||||
"The content in head version should be equal to the content we started with:",
|
||||
contentWeStartedWith.equals(content));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal invariant here because it is not the initial version
|
||||
Triplet testTriplet = new Triplet(content);
|
||||
assertTrue(testTriplet.locale.equals(currentVersionLocale.toString()));
|
||||
assertTrue(testTriplet.edition.equals(editionLabel));
|
||||
assertTrue(testTriplet.version.equals(versionLabel));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private
|
||||
NodeRef createMLContainerWithContent(String editionSuffix)
|
||||
{
|
||||
NodeRef chineseContentNodeRef = createContent(CHINESE_CONTENT + "-" + Locale.CHINESE + "-" + editionSuffix
|
||||
+ "-0.1");
|
||||
NodeRef frenchContentNodeRef = createContent(FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + editionSuffix
|
||||
+ "-0.1");
|
||||
NodeRef japaneseContentNodeRef = createContent(JAPANESE_CONTENT + "-" + Locale.JAPANESE + "-" + editionSuffix
|
||||
+ "-0.1");
|
||||
|
||||
multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
|
||||
multilingualContentService.addTranslation(frenchContentNodeRef, chineseContentNodeRef, Locale.FRENCH);
|
||||
multilingualContentService.addTranslation(japaneseContentNodeRef, chineseContentNodeRef, Locale.JAPANESE);
|
||||
|
||||
return multilingualContentService.getTranslationContainer(chineseContentNodeRef);
|
||||
}
|
||||
|
||||
private void modifyContent(NodeRef nodeRef, String value)
|
||||
{
|
||||
ContentWriter contentWriter = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
|
||||
contentWriter.putContent(value);
|
||||
}
|
||||
|
||||
private void dumpFrozenMetaData(Version editionVersion)
|
||||
{
|
||||
System.out.println("---------------------------------------------------");
|
||||
//Get current version label
|
||||
System.out.println("Version Label: " + editionVersion.getVersionLabel());
|
||||
System.out.println("---------------------------------------------------");
|
||||
//Map<QName,Serializable> mapOfFrozenProps = editionService.getVersionedMetadatas(editionVersion);
|
||||
Map<String,Serializable> mapOfFrozenProps = editionVersion.getVersionProperties();
|
||||
if(mapOfFrozenProps == null )
|
||||
{
|
||||
System.out.println("Nul... ");
|
||||
return;
|
||||
}
|
||||
|
||||
for(String q: mapOfFrozenProps.keySet())
|
||||
{
|
||||
String val = mapOfFrozenProps.get(q)==null?"null":mapOfFrozenProps.get(q).toString();
|
||||
System.out.println("QName:" + q + ":" + val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse the content to extract the local,edition lablel,version label
|
||||
*
|
||||
* @author Philippe Dubois
|
||||
*/
|
||||
private class Triplet
|
||||
{
|
||||
public String locale;
|
||||
public String edition;
|
||||
public String version;
|
||||
|
||||
public Triplet(String content)
|
||||
{
|
||||
String[] tokens = content.split("-");
|
||||
locale = tokens[1];
|
||||
edition = tokens[2];
|
||||
version = tokens[3];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected NodeRef createContent(String name)
|
||||
{
|
||||
NodeRef contentNodeRef = fileFolderService.create(folderNodeRef, name+".txt", ContentModel.TYPE_CONTENT).getNodeRef();
|
||||
// add some content
|
||||
ContentWriter contentWriter = fileFolderService.getWriter(contentNodeRef);
|
||||
contentWriter.putContent(name);
|
||||
// done
|
||||
return contentNodeRef;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user