mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
REPO-3040 Make TransferVersionCheckerImpl less restrictive (#41)
This commit is contained in:
@@ -1,28 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
* provided under the following open source license terms:
|
* provided under the following open source license terms:
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.transfer;
|
package org.alfresco.repo.transfer;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.transfer.TransferVersion;
|
import org.alfresco.service.cmr.transfer.TransferVersion;
|
||||||
@@ -32,7 +32,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
/**
|
/**
|
||||||
* This is an implementation of TransferVersionChecker.
|
* This is an implementation of TransferVersionChecker.
|
||||||
*
|
*
|
||||||
* It allows transfer to the same edition/major/minor but ignores revision.
|
* It allows transfer to the same major version.
|
||||||
*/
|
*/
|
||||||
public class TransferVersionCheckerImpl implements TransferVersionChecker
|
public class TransferVersionCheckerImpl implements TransferVersionChecker
|
||||||
{
|
{
|
||||||
@@ -42,26 +42,16 @@ public class TransferVersionCheckerImpl implements TransferVersionChecker
|
|||||||
{
|
{
|
||||||
logger.debug("checkTransferVersions from:" + from + ", to:" + to);
|
logger.debug("checkTransferVersions from:" + from + ", to:" + to);
|
||||||
|
|
||||||
if(from == null || to == null || to.getEdition() == null || to.getVersionMajor() == null || to.getVersionMinor() == null)
|
if(from == null || to == null || from.getVersionMajor() == null || to.getVersionMajor() == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!from.getEdition().equalsIgnoreCase(to.getEdition()))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!from.getVersionMajor().equalsIgnoreCase(to.getVersionMajor()))
|
if(!from.getVersionMajor().equalsIgnoreCase(to.getVersionMajor()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!from.getVersionMinor().equalsIgnoreCase(to.getVersionMinor()))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ignore revisions
|
// ignore revisions
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@@ -74,6 +74,7 @@ import org.junit.runners.Suite;
|
|||||||
org.alfresco.repo.transfer.ContentChunkerImplTest.class,
|
org.alfresco.repo.transfer.ContentChunkerImplTest.class,
|
||||||
org.alfresco.repo.transfer.HttpClientTransmitterImplTest.class,
|
org.alfresco.repo.transfer.HttpClientTransmitterImplTest.class,
|
||||||
org.alfresco.repo.transfer.manifest.TransferManifestTest.class,
|
org.alfresco.repo.transfer.manifest.TransferManifestTest.class,
|
||||||
|
org.alfresco.repo.transfer.TransferVersionCheckerImplTest.class,
|
||||||
org.alfresco.repo.urlshortening.BitlyUrlShortenerTest.class,
|
org.alfresco.repo.urlshortening.BitlyUrlShortenerTest.class,
|
||||||
org.alfresco.service.cmr.calendar.CalendarRecurrenceHelperTest.class,
|
org.alfresco.service.cmr.calendar.CalendarRecurrenceHelperTest.class,
|
||||||
org.alfresco.service.cmr.calendar.CalendarTimezoneHelperTest.class,
|
org.alfresco.service.cmr.calendar.CalendarTimezoneHelperTest.class,
|
||||||
|
@@ -81,7 +81,6 @@ import org.junit.runners.Suite;
|
|||||||
org.alfresco.repo.transfer.TransferServiceCallbackTest.class,
|
org.alfresco.repo.transfer.TransferServiceCallbackTest.class,
|
||||||
org.alfresco.repo.transfer.TransferServiceImplTest.class,
|
org.alfresco.repo.transfer.TransferServiceImplTest.class,
|
||||||
org.alfresco.repo.transfer.TransferServiceToBeRefactoredTest.class,
|
org.alfresco.repo.transfer.TransferServiceToBeRefactoredTest.class,
|
||||||
org.alfresco.repo.transfer.TransferVersionCheckerImplTest.class,
|
|
||||||
org.alfresco.repo.transfer.manifest.ManifestIntegrationTest.class,
|
org.alfresco.repo.transfer.manifest.ManifestIntegrationTest.class,
|
||||||
org.alfresco.repo.transfer.script.ScriptTransferServiceTest.class,
|
org.alfresco.repo.transfer.script.ScriptTransferServiceTest.class,
|
||||||
org.alfresco.util.schemacomp.DbToXMLTest.class,
|
org.alfresco.util.schemacomp.DbToXMLTest.class,
|
||||||
|
@@ -1,45 +1,46 @@
|
|||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
* provided under the following open source license terms:
|
* provided under the following open source license terms:
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.transfer;
|
package org.alfresco.repo.transfer;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.transfer.TransferVersion;
|
import org.alfresco.service.cmr.transfer.TransferVersion;
|
||||||
import org.alfresco.test_category.BaseSpringTestsCategory;
|
import org.junit.Test;
|
||||||
import org.alfresco.util.BaseAlfrescoSpringTest;
|
|
||||||
import org.junit.experimental.categories.Category;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit test for TransferVersionChecker
|
* Unit test for TransferVersionChecker
|
||||||
* @author mrogers
|
* @author mrogers
|
||||||
*/
|
*/
|
||||||
@Category(BaseSpringTestsCategory.class)
|
public class TransferVersionCheckerImplTest
|
||||||
public class TransferVersionCheckerImplTest extends BaseAlfrescoSpringTest
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test TransferVersionCheckerImpl
|
* Test TransferVersionCheckerImpl
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testTransferVersionCheckerImpl()
|
public void testTransferVersionCheckerImpl()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -61,11 +62,10 @@ public class TransferVersionCheckerImplTest extends BaseAlfrescoSpringTest
|
|||||||
assertTrue("not equals", checker.checkTransferVersions(e, new TransferVersionImpl("3", "3", "1", EDITION)));
|
assertTrue("not equals", checker.checkTransferVersions(e, new TransferVersionImpl("3", "3", "1", EDITION)));
|
||||||
assertTrue("not equals", checker.checkTransferVersions(e, new TransferVersionImpl("3", "3", "2", EDITION)));
|
assertTrue("not equals", checker.checkTransferVersions(e, new TransferVersionImpl("3", "3", "2", EDITION)));
|
||||||
|
|
||||||
// These should not match
|
assertTrue("Checker should not flag minor difference", checker.checkTransferVersions(e, new TransferVersionImpl("3", "4", "0", EDITION)));
|
||||||
assertFalse("not equals minor different", checker.checkTransferVersions(e, new TransferVersionImpl("3", "4", "0", EDITION)));
|
assertFalse("Checker should flag major difference", checker.checkTransferVersions(e, new TransferVersionImpl("4", "3", "0", EDITION)));
|
||||||
assertFalse("not equals major different", checker.checkTransferVersions(e, new TransferVersionImpl("4", "3", "0", EDITION)));
|
assertTrue("Checker should not flag edition difference", checker.checkTransferVersions(e, new TransferVersionImpl("3", "3", "0", "Whatever")));
|
||||||
assertFalse("not equals edition different", checker.checkTransferVersions(e, new TransferVersionImpl("3", "3", "0", "Whatever")));
|
assertTrue("Checker should not flag edition absence", checker.checkTransferVersions(e, new TransferVersionImpl("3", "3", "0", null)));
|
||||||
assertFalse("not equals edition null ", checker.checkTransferVersions(e, new TransferVersionImpl("3", "3", "0", null)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user