diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml
index 8dc056b065..dd1d40a33a 100644
--- a/config/alfresco/bootstrap-context.xml
+++ b/config/alfresco/bootstrap-context.xml
@@ -123,6 +123,7 @@
+
diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml
index d18e4afa56..8198a286cf 100644
--- a/config/alfresco/core-services-context.xml
+++ b/config/alfresco/core-services-context.xml
@@ -886,9 +886,6 @@
-
-
-
@@ -977,23 +974,6 @@
-
-
- org.alfresco.repo.version.common.counter.VersionCounterService
-
-
-
-
-
-
-
-
-
- ${server.transaction.mode.default}, PROPAGATION_REQUIRES_NEW
-
-
-
-
diff --git a/config/alfresco/dbscripts/upgrade/3.3/org.hibernate.dialect.Dialect/remove-VersionCount.sql b/config/alfresco/dbscripts/upgrade/3.3/org.hibernate.dialect.Dialect/remove-VersionCount.sql
new file mode 100644
index 0000000000..2a5461b404
--- /dev/null
+++ b/config/alfresco/dbscripts/upgrade/3.3/org.hibernate.dialect.Dialect/remove-VersionCount.sql
@@ -0,0 +1,24 @@
+--
+-- Title: Upgrade to V3.3 - Remove Version Count
+-- Database: Generic
+-- Since: V3.3 schema 4003
+-- Author: janv
+--
+-- remove (obsolete) version count table
+--
+-- Please contact support@alfresco.com if you need assistance with the upgrade.
+--
+
+drop table alf_version_count;
+
+--
+-- Record script finish
+--
+DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.3-Remove-VersionCount';
+INSERT INTO alf_applied_patch
+ (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
+ VALUES
+ (
+ 'patch.db-V3.3-Remove-VersionCount', 'Manually executed script upgrade V3.3 to remove Version Count',
+ 0, 4002, -1, 4003, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed'
+ );
diff --git a/config/alfresco/ehcache-default.xml b/config/alfresco/ehcache-default.xml
index a379cc58e4..b26824bc19 100644
--- a/config/alfresco/ehcache-default.xml
+++ b/config/alfresco/ehcache-default.xml
@@ -70,14 +70,6 @@
eternal="true"
overflowToDisk="false"
/>
-
-
-
-
-
-
-
-
org/alfresco/repo/domain/hibernate/Locale.hbm.xml
org/alfresco/repo/domain/hibernate/Node.hbm.xmlorg/alfresco/repo/domain/hibernate/Transaction.hbm.xml
- org/alfresco/repo/domain/hibernate/VersionCount.hbm.xmlorg/alfresco/repo/domain/hibernate/Permission.hbm.xmlorg/alfresco/repo/attributes/hibernate/Attributes.hbm.xmlorg/alfresco/repo/domain/hibernate/UsageDelta.hbm.xml
@@ -172,7 +171,6 @@
${cache.strategy}${cache.strategy}${cache.strategy}
- ${cache.strategy}${cache.strategy}${cache.strategy}
@@ -206,12 +204,6 @@
-
-
-
-
-
-
org.alfresco.repo.security.permissions.impl.PermissionsDaoComponent
diff --git a/config/alfresco/import-export-context.xml b/config/alfresco/import-export-context.xml
index 562ffd7bf3..9f59b7e648 100644
--- a/config/alfresco/import-export-context.xml
+++ b/config/alfresco/import-export-context.xml
@@ -175,13 +175,10 @@
-
+
-
-
-
diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml
index 41d3e6d886..ac11f9d906 100644
--- a/config/alfresco/patch/patch-services-context.xml
+++ b/config/alfresco/patch/patch-services-context.xml
@@ -1638,18 +1638,6 @@
-
- patch.migrateVersionStoreUpdateCounter
- patch.migrateVersionStoreUpdateCounter.description
- 0
- 2004
- 2005
-
-
-
-
-
-
patch.db-V2.2-Person-3patch.schemaUpgradeScript.description
@@ -2003,7 +1991,7 @@
-
+
patch.db-V3.2-ContentTables2patch.schemaUpgradeScript.description
@@ -2020,4 +2008,16 @@
+
+
+ patch.db-V3.3-Remove-VersionCount
+ patch.schemaUpgradeScript.description
+ 0
+ 4002
+ 4003
+
+ classpath:alfresco/dbscripts/upgrade/3.3/${db.script.dialect}/remove-VersionCount.sql
+
+
+
diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties
index 463d9063b3..b208615df6 100644
--- a/config/alfresco/version.properties
+++ b/config/alfresco/version.properties
@@ -19,4 +19,4 @@ version.build=@build-number@
# Schema number
-version.schema=4002
+version.schema=4003
diff --git a/source/java/org/alfresco/repo/admin/patch/impl/MigrateVersionStoreUpdateCounterPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/MigrateVersionStoreUpdateCounterPatch.java
deleted file mode 100644
index 526386c81b..0000000000
--- a/source/java/org/alfresco/repo/admin/patch/impl/MigrateVersionStoreUpdateCounterPatch.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program 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 General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing
- */
-package org.alfresco.repo.admin.patch.impl;
-
-import org.springframework.extensions.surf.util.I18NUtil;
-import org.alfresco.repo.admin.patch.AbstractPatch;
-import org.alfresco.repo.version.Version2Model;
-import org.alfresco.repo.version.VersionModel;
-import org.alfresco.repo.version.common.counter.VersionCounterService;
-import org.alfresco.service.cmr.repository.StoreRef;
-
-/**
- * Update internal version2Store counter if needed (eg. affects upgrades from 2.x to 3.0.1, will not affect upgrades from 2.x to 3.1.0)
- */
-public class MigrateVersionStoreUpdateCounterPatch extends AbstractPatch
-{
- private static final String MSG_SUCCESS = "patch.migrateVersionStoreUpdateCounter.result";
-
- private VersionCounterService versionCounterService;
-
- public void setVersionCounterService(VersionCounterService versionCounterService)
- {
- this.versionCounterService = versionCounterService;
- }
-
- @Override
- protected String applyInternal() throws Exception
- {
- int oldV1count = versionCounterService.currentVersionNumber(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, VersionModel.STORE_ID));
- int oldV2count = versionCounterService.currentVersionNumber(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, Version2Model.STORE_ID));
-
- int newV2count = (oldV1count+oldV2count);
- versionCounterService.setVersionNumber(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, Version2Model.STORE_ID), newV2count);
-
- // build the result message
- String msg = I18NUtil.getMessage(MSG_SUCCESS, "oldV1count="+oldV1count+",oldV2count="+oldV2count+",newV2count="+newV2count);
-
- // done
- return msg;
- }
-}
diff --git a/source/java/org/alfresco/repo/domain/VersionCount.java b/source/java/org/alfresco/repo/domain/VersionCount.java
deleted file mode 100644
index be2fd616c2..0000000000
--- a/source/java/org/alfresco/repo/domain/VersionCount.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program 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 General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.domain;
-
-/**
- * Represents a version count entity for a particular store.
- *
- * @author Derek Hulley
- */
-public interface VersionCount
-{
- /**
- * @return Returns the auto-generated ID
- */
- public Long getId();
-
- /**
- * @return Returns the associated store
- */
- public Store getStore();
-
- public void setStore(Store store);
-
- /**
- * Increments and returns the next version counter associated with this
- * store.
- *
- * @return Returns the next version counter in the sequence
- *
- * @see #getVersionCount()
- */
- public int incrementVersionCount();
-
- /**
- * Reset the store's version counter
- */
- public void resetVersionCount();
-
- /**
- * Retrieve the current version counter
- *
- * @return Returns a current version counter
- *
- * @see #incrementVersionCount()
- */
- public int getVersionCount();
-
- /**
- * Sets the current version counter
- *
- * @param versionCount the new version counter
- */
- public void setVersionCount(int versionCount);
-}
diff --git a/source/java/org/alfresco/repo/domain/hibernate/VersionCount.hbm.xml b/source/java/org/alfresco/repo/domain/hibernate/VersionCount.hbm.xml
deleted file mode 100644
index aa6a521934..0000000000
--- a/source/java/org/alfresco/repo/domain/hibernate/VersionCount.hbm.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- select
- cnt
- from
- org.alfresco.repo.domain.hibernate.VersionCountImpl as cnt
- where
- cnt.store.protocol = :protocol and
- cnt.store.identifier = :identifier
-
-
-
diff --git a/source/java/org/alfresco/repo/domain/hibernate/VersionCountImpl.java b/source/java/org/alfresco/repo/domain/hibernate/VersionCountImpl.java
deleted file mode 100644
index 4c3023dd5a..0000000000
--- a/source/java/org/alfresco/repo/domain/hibernate/VersionCountImpl.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program 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 General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.domain.hibernate;
-
-import java.io.Serializable;
-
-import org.alfresco.repo.domain.Store;
-import org.alfresco.repo.domain.VersionCount;
-
-/**
- * Hibernate-specific implementation of the domain entity versioncounter.
- *
- * @author Derek Hulley
- */
-public class VersionCountImpl implements VersionCount, Serializable
-{
- private static final long serialVersionUID = 7778431129424069297L;
-
- private Long id;
- private Store store;
- private long version;
- private int versionCount;
-
- public VersionCountImpl()
- {
- versionCount = 0;
- }
-
- /**
- * @see #getKey()
- */
- public boolean equals(Object obj)
- {
- if (obj == null)
- {
- return false;
- }
- else if (obj == this)
- {
- return true;
- }
- else if (!(obj instanceof VersionCount))
- {
- return false;
- }
- VersionCount that = (VersionCount) obj;
- return (this.getStore().equals(that.getStore()));
- }
-
- /**
- * @see #getKey()
- */
- public int hashCode()
- {
- return getStore().hashCode();
- }
-
- /**
- * @see #getKey()
- */
- public String toString()
- {
- return getStore().toString();
- }
-
- public Long getId()
- {
- return id;
- }
-
- /**
- * For Hibernate use
- */
- @SuppressWarnings("unused")
- private void setId(Long id)
- {
- this.id = id;
- }
-
- public Store getStore()
- {
- return store;
- }
-
- public void setStore(Store store)
- {
- this.store = store;
- }
-
- public Long getVersion()
- {
- return version;
- }
-
- /**
- * For Hibernate use
- */
- @SuppressWarnings("unused")
- private void setVersion(Long version)
- {
- this.version = version;
- }
-
- /**
- * For Hibernate use
- */
- public void setVersionCount(int versionCount)
- {
- this.versionCount = versionCount;
- }
-
- public int incrementVersionCount()
- {
- int versionCount = getVersionCount() + 1;
- setVersionCount(versionCount);
- return versionCount;
- }
-
- /**
- * Reset back to 0
- */
- public void resetVersionCount()
- {
- setVersionCount(0);
- }
-
- public int getVersionCount()
- {
- return versionCount;
- }
-}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/domain/hibernate/VersionCounterDaoComponentImpl.java b/source/java/org/alfresco/repo/domain/hibernate/VersionCounterDaoComponentImpl.java
deleted file mode 100644
index ba7c3a4831..0000000000
--- a/source/java/org/alfresco/repo/domain/hibernate/VersionCounterDaoComponentImpl.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program 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 General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.domain.hibernate;
-
-import org.alfresco.repo.domain.Store;
-import org.alfresco.repo.domain.VersionCount;
-import org.alfresco.repo.version.common.counter.VersionCounterService;
-import org.alfresco.service.cmr.repository.InvalidStoreRefException;
-import org.alfresco.service.cmr.repository.StoreRef;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.springframework.orm.hibernate3.HibernateCallback;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-
-/**
- * Version counter DAO service implemtation using Hibernate.
- *
- * The object should execute within its own transaction, and is limited to single-thread
- * entry. If it becomes a bottleneck, the transaction synchronization should be moved
- * over to reentrant locks and/or the hibernate mappings should be optimized for better
- * read-write access.
- *
- * @author Derek Hulley
- */
-public class VersionCounterDaoComponentImpl
- extends HibernateDaoSupport
- implements VersionCounterService
-{
- private static final String QUERY_GET_VERSION_COUNT_FOR_STORE = "versionCount.GetVersionCountForStore";
- private static final String QUERY_GET_STORE_BY_ALL = "store.GetStoreByAll";
-
- /**
- * Retrieves or creates a version counter. This locks the counter against updates for the
- * current transaction.
- *
- * @param storeKey the primary key of the counter
- * @param create true to create on demand
- * @return Returns a current or new version counter
- */
- private VersionCount getVersionCounter(final StoreRef storeRef, boolean create)
- {
- HibernateCallback callback = new HibernateCallback()
- {
- public Object doInHibernate(Session session)
- {
- Query query = session
- .getNamedQuery(VersionCounterDaoComponentImpl.QUERY_GET_VERSION_COUNT_FOR_STORE)
- .setString("protocol", storeRef.getProtocol())
- .setString("identifier", storeRef.getIdentifier());
- return query.uniqueResult();
- }
- };
- VersionCount versionCount = (VersionCount) getHibernateTemplate().execute(callback);
-
- // Done if it exists
- if (versionCount != null)
- {
- // Debug
- if (logger.isDebugEnabled())
- {
- logger.debug("Got version counter: \n" +
- " Thread: " + Thread.currentThread().getName() + "\n" +
- " Version count: " + versionCount.getVersionCount());
- }
- // Done
- return versionCount;
- }
- else if (!create)
- {
- return null;
- }
-
- // We have permission to create
- callback = new HibernateCallback()
- {
- public Object doInHibernate(Session session)
- {
- Query query = session
- .getNamedQuery(VersionCounterDaoComponentImpl.QUERY_GET_STORE_BY_ALL)
- .setString("protocol", storeRef.getProtocol())
- .setString("identifier", storeRef.getIdentifier());
- return query.uniqueResult();
- }
- };
- Store store = (Store) getHibernateTemplate().execute(callback);
- if (store == null)
- {
- throw new InvalidStoreRefException(storeRef);
- }
- versionCount = new VersionCountImpl();
- versionCount.setStore(store);
- getHibernateTemplate().save(versionCount);
-
- // Debug
- if (logger.isDebugEnabled())
- {
- logger.debug("Created version counter: \n" +
- " Thread: " + Thread.currentThread().getName() + "\n" +
- " Version count: " + versionCount.getVersionCount());
- }
-
- // Done
- return versionCount;
- }
-
- /**
- * Get the next available version number for the specified store.
- *
- * @param storeRef the version store id
- * @return the next version number
- */
- public int nextVersionNumber(StoreRef storeRef)
- {
- // get the version counter
- VersionCount versionCount = getVersionCounter(storeRef, true);
- // get an incremented count
- int nextCount = versionCount.incrementVersionCount();
-
- // done
- if (logger.isDebugEnabled())
- {
- logger.debug("Incremented version count: \n" +
- " Thread: " + Thread.currentThread().getName() + "\n" +
- " New version count: " + versionCount.getVersionCount());
- }
- return nextCount;
- }
-
- /**
- * Gets the current version number for the specified store.
- *
- * @param storeRef the store reference
- * @return the current version number, zero if no version yet allocated.
- */
- public int currentVersionNumber(StoreRef storeRef)
- {
- // get the version counter
- VersionCount versionCounter = getVersionCounter(storeRef, false);
- // get an incremented count
- return versionCounter == null ? 0 : versionCounter.getVersionCount();
- }
-
- /**
- * Resets the version number for a the specified store.
- *
- * WARNING: calling this method will completely reset the current
- * version count for the specified store and cannot be undone.
- *
- * @param storeRef the store reference
- */
- public synchronized void resetVersionNumber(StoreRef storeRef)
- {
- // get the version counter
- VersionCount versionCounter = getVersionCounter(storeRef, true);
- // get an incremented count
- versionCounter.resetVersionCount();
- }
-
- /**
- * Sets the version number for a specified store.
- *
- * WARNING: calling this method will completely reset the current
- * version count for the specified store and cannot be undone.
- *
- * @param storeRef the store reference
- * @param versionCount the new version count
- */
- public synchronized void setVersionNumber(StoreRef storeRef, int versionCount)
- {
- // get the version counter
- VersionCount versionCounter = getVersionCounter(storeRef, true);
- // get an incremented count
- versionCounter.setVersionCount(versionCount);
- }
-}
diff --git a/source/java/org/alfresco/repo/importer/system/SystemExporterImporter.java b/source/java/org/alfresco/repo/importer/system/SystemExporterImporter.java
index fcbb59161c..fa3c9bce61 100644
--- a/source/java/org/alfresco/repo/importer/system/SystemExporterImporter.java
+++ b/source/java/org/alfresco/repo/importer/system/SystemExporterImporter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -30,9 +30,7 @@ import java.util.List;
import org.alfresco.repo.admin.patch.AppliedPatch;
import org.alfresco.repo.domain.patch.AppliedPatchDAO;
-import org.alfresco.repo.version.common.counter.VersionCounterService;
import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.cmr.repository.StoreRef;
/**
@@ -45,8 +43,6 @@ public class SystemExporterImporter
// dependencies
private NodeService nodeService;
private AppliedPatchDAO appliedPatchDAO;
- private VersionCounterService versionCounterService;
-
public void setNodeService(NodeService nodeService)
{
@@ -58,12 +54,6 @@ public class SystemExporterImporter
this.appliedPatchDAO = appliedPatchDAO;
}
- public void setVersionCounterService(VersionCounterService versionCounterService)
- {
- this.versionCounterService = versionCounterService;
- }
-
-
/**
* Export Repository System Information
*
@@ -91,17 +81,6 @@ public class SystemExporterImporter
patchInfo.wasExecuted = patch.getWasExecuted();
systemInfo.patches.add(patchInfo);
}
-
- // capture version counters
- List storeRefs = nodeService.getStores();
- for (StoreRef storeRef : storeRefs)
- {
- VersionCounterInfo versionCounterInfo = new VersionCounterInfo();
- int versionCount = versionCounterService.currentVersionNumber(storeRef);
- versionCounterInfo.storeRef = storeRef.toString();
- versionCounterInfo.count = versionCount;
- systemInfo.versionCounters.add(versionCounterInfo);
- }
systemInfo.toXML(exportStream);
}
@@ -133,13 +112,5 @@ public class SystemExporterImporter
patch.setWasExecuted(patchInfo.wasExecuted);
appliedPatchDAO.createAppliedPatch(patch);
}
-
- // apply version counters
- for (VersionCounterInfo versionCounterInfo : systemInfo.versionCounters)
- {
- StoreRef storeRef = new StoreRef(versionCounterInfo.storeRef);
- versionCounterService.setVersionNumber(storeRef, versionCounterInfo.count);
- }
}
-
}
diff --git a/source/java/org/alfresco/repo/importer/system/SystemInfo.java b/source/java/org/alfresco/repo/importer/system/SystemInfo.java
index 0a3a8251fb..53c0b585c1 100644
--- a/source/java/org/alfresco/repo/importer/system/SystemInfo.java
+++ b/source/java/org/alfresco/repo/importer/system/SystemInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -45,7 +45,6 @@ import org.jibx.runtime.JiBXException;
public class SystemInfo
{
public List patches = new ArrayList();
- public List versionCounters = new ArrayList();
/**
* Create System Info from XML representation
@@ -87,7 +86,4 @@ public class SystemInfo
throw new DictionaryException("Failed to create System Info", e);
}
}
-
}
-
-
diff --git a/source/java/org/alfresco/repo/importer/system/VersionCounterInfo.java b/source/java/org/alfresco/repo/importer/system/VersionCounterInfo.java
deleted file mode 100644
index abf6161c7b..0000000000
--- a/source/java/org/alfresco/repo/importer/system/VersionCounterInfo.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program 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 General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.importer.system;
-
-
-/**
- * Data holder of Version information to be exported and imported
- *
- * @author davidc
- */
-public class VersionCounterInfo
-{
- public String storeRef = null;
- public Integer count = null;
-}
diff --git a/source/java/org/alfresco/repo/importer/system/systeminfo.xml b/source/java/org/alfresco/repo/importer/system/systeminfo.xml
index c25d390bbe..4704af5da3 100644
--- a/source/java/org/alfresco/repo/importer/system/systeminfo.xml
+++ b/source/java/org/alfresco/repo/importer/system/systeminfo.xml
@@ -23,12 +23,6 @@
-
-
-
-
-
-
diff --git a/source/java/org/alfresco/repo/version/BaseVersionStoreTest.java b/source/java/org/alfresco/repo/version/BaseVersionStoreTest.java
index cf9333165e..3d0af73904 100644
--- a/source/java/org/alfresco/repo/version/BaseVersionStoreTest.java
+++ b/source/java/org/alfresco/repo/version/BaseVersionStoreTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2009 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -40,7 +40,6 @@ import org.alfresco.repo.node.archive.NodeArchiveService;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
-import org.alfresco.repo.version.common.counter.VersionCounterService;
import org.alfresco.repo.version.common.versionlabel.SerialVersionLabelPolicy;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentService;
@@ -59,14 +58,13 @@ import org.alfresco.util.BaseSpringTest;
public abstract class BaseVersionStoreTest extends BaseSpringTest
{
- /*
+ /*
* Services used by the tests
*/
- protected NodeService dbNodeService;
+ protected NodeService dbNodeService;
protected VersionService versionService;
- protected VersionCounterService versionCounterDaoService;
protected ContentService contentService;
- protected DictionaryDAO dictionaryDAO;
+ protected DictionaryDAO dictionaryDAO;
protected MutableAuthenticationService authenticationService;
protected TransactionService transactionService;
protected RetryingTransactionHelper txnHelper;
@@ -74,7 +72,7 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
protected NodeArchiveService nodeArchiveService;
protected NodeService nodeService;
protected PermissionService permissionService;
-
+
/*
* Data used by tests
*/
@@ -89,24 +87,24 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
protected HashMap versionableNodes;
/*
- * Proprety names and values
+ * Property names and values
*/
protected static final String TEST_NAMESPACE = "http://www.alfresco.org/test/versionstorebasetest/1.0";
- protected static final QName TEST_TYPE_QNAME = QName.createQName(TEST_NAMESPACE, "testtype");
+ protected static final QName TEST_TYPE_QNAME = QName.createQName(TEST_NAMESPACE, "testtype");
protected static final QName TEST_ASPECT_QNAME = QName.createQName(TEST_NAMESPACE, "testaspect");
- protected static final QName PROP_1 = QName.createQName(TEST_NAMESPACE, "prop1");
- protected static final QName PROP_2 = QName.createQName(TEST_NAMESPACE, "prop2");
- protected static final QName PROP_3 = QName.createQName(TEST_NAMESPACE, "prop3");
+ protected static final QName PROP_1 = QName.createQName(TEST_NAMESPACE, "prop1");
+ protected static final QName PROP_2 = QName.createQName(TEST_NAMESPACE, "prop2");
+ protected static final QName PROP_3 = QName.createQName(TEST_NAMESPACE, "prop3");
protected static final QName MULTI_PROP = QName.createQName(TEST_NAMESPACE, "multiProp");
- protected static final String VERSION_PROP_1 = "versionProp1";
- protected static final String VERSION_PROP_2 = "versionProp2";
- protected static final String VERSION_PROP_3 = "versionProp3";
- protected static final String VALUE_1 = "value1";
- protected static final String VALUE_2 = "value2";
- protected static final String VALUE_3 = "value3";
- protected static final QName TEST_CHILD_ASSOC_1 = QName.createQName(TEST_NAMESPACE, "childassoc1");
- protected static final QName TEST_CHILD_ASSOC_2 = QName.createQName(TEST_NAMESPACE, "childassoc2");
- protected static final QName TEST_ASSOC = QName.createQName(TEST_NAMESPACE, "assoc1");
+ protected static final String VERSION_PROP_1 = "versionProp1";
+ protected static final String VERSION_PROP_2 = "versionProp2";
+ protected static final String VERSION_PROP_3 = "versionProp3";
+ protected static final String VALUE_1 = "value1";
+ protected static final String VALUE_2 = "value2";
+ protected static final String VALUE_3 = "value3";
+ protected static final QName TEST_CHILD_ASSOC_1 = QName.createQName(TEST_NAMESPACE, "childassoc1");
+ protected static final QName TEST_CHILD_ASSOC_2 = QName.createQName(TEST_NAMESPACE, "childassoc2");
+ protected static final QName TEST_ASSOC = QName.createQName(TEST_NAMESPACE, "assoc1");
protected Collection multiValue = null;
protected static final String MULTI_VALUE_1 = "multi1";
@@ -155,7 +153,6 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
// Get the services by name from the application context
this.dbNodeService = (NodeService)applicationContext.getBean("dbNodeService");
- this.versionCounterDaoService = (VersionCounterService)applicationContext.getBean("versionCounterService");
this.contentService = (ContentService)applicationContext.getBean("contentService");
this.authenticationService = (MutableAuthenticationService)applicationContext.getBean("authenticationService");
this.transactionService = (TransactionService)this.applicationContext.getBean("transactionComponent");
@@ -176,7 +173,7 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
this.versionProperties = new HashMap();
versionProperties.put(VERSION_PROP_1, VALUE_1);
versionProperties.put(VERSION_PROP_2, VALUE_2);
- versionProperties.put(VERSION_PROP_3, VALUE_3);
+ versionProperties.put(VERSION_PROP_3, VALUE_3);
// Create the node properties
this.nodeProperties = new HashMap();
@@ -188,7 +185,7 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
// Add mlText property
this.mlText = new MLText(Locale.UK, "UK value");
- this.mlText.addValue(Locale.US, "Y'all US value");
+ this.mlText.addValue(Locale.US, "Y'all US value");
this.nodeProperties.put(MLTEXT_PROP, this.mlText);
// Create a workspace that contains the 'live' nodes
@@ -249,10 +246,10 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}MyVersionableNode"),
TEST_TYPE_QNAME,
- this.nodeProperties).getChildRef();
+ this.nodeProperties).getChildRef();
if (versionable)
{
- this.dbNodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, new HashMap());
+ this.dbNodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, new HashMap());
}
assertNotNull(nodeRef);
@@ -270,23 +267,23 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
// Add some children to the node
NodeRef child1 = this.dbNodeService.createNode(
nodeRef,
- TEST_CHILD_ASSOC_1,
TEST_CHILD_ASSOC_1,
- TEST_TYPE_QNAME,
+ TEST_CHILD_ASSOC_1,
+ TEST_TYPE_QNAME,
this.nodeProperties).getChildRef();
if (versionable)
{
- this.dbNodeService.addAspect(child1, ContentModel.ASPECT_VERSIONABLE, new HashMap());
+ this.dbNodeService.addAspect(child1, ContentModel.ASPECT_VERSIONABLE, new HashMap());
}
assertNotNull(child1);
this.versionableNodes.put(child1.getId(), child1);
NodeRef child2 = this.dbNodeService.createNode(
nodeRef,
- TEST_CHILD_ASSOC_2,
TEST_CHILD_ASSOC_2,
- TEST_TYPE_QNAME,
+ TEST_CHILD_ASSOC_2,
+ TEST_TYPE_QNAME,
this.nodeProperties).getChildRef();
if (versionable)
@@ -300,9 +297,9 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
// Create a node that can be associated with the root node
NodeRef assocNode = this.dbNodeService.createNode(
rootNodeRef,
- ContentModel.ASSOC_CHILDREN,
+ ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}MyAssocNode"),
- TEST_TYPE_QNAME,
+ TEST_TYPE_QNAME,
this.nodeProperties).getChildRef();
assertNotNull(assocNode);
this.dbNodeService.createAssociation(nodeRef, assocNode, TEST_ASSOC);
@@ -332,16 +329,15 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
*/
protected Version createVersion(NodeRef versionableNode, Map versionProperties)
{
- // Get the next version number
- int nextVersion = peekNextVersionNumber();
- String nextVersionLabel = peekNextVersionLabel(versionableNode, nextVersion, versionProperties);
-
+ // Get the next version label
+ String nextVersionLabel = peekNextVersionLabel(versionableNode, versionProperties);
+
// Snap-shot the node created date-time
long beforeVersionTime = ((Date)nodeService.getProperty(versionableNode, ContentModel.PROP_CREATED)).getTime();
// Now lets create a new version for this node
Version newVersion = versionService.createVersion(versionableNode, this.versionProperties);
- checkNewVersion(beforeVersionTime, nextVersion, nextVersionLabel, newVersion, versionableNode);
+ checkNewVersion(beforeVersionTime, nextVersionLabel, newVersion, versionableNode);
// Return the new version
return newVersion;
@@ -349,9 +345,8 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
protected Collection createVersion(NodeRef versionableNode, Map versionProperties, boolean versionChildren)
{
- // Get the next version number
- int nextVersion = peekNextVersionNumber();
- String nextVersionLabel = peekNextVersionLabel(versionableNode, nextVersion, versionProperties);
+ // Get the next version label
+ String nextVersionLabel = peekNextVersionLabel(versionableNode, versionProperties);
// Snap-shot the node created date-time
long beforeVersionTime = ((Date)nodeService.getProperty(versionableNode, ContentModel.PROP_CREATED)).getTime();
@@ -360,56 +355,49 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
Collection versions = versionService.createVersion(versionableNode, this.versionProperties, versionChildren);
// Check the returned versions are correct
- checkVersionCollection(nextVersion, nextVersionLabel, beforeVersionTime, versions);
+ checkVersionCollection(nextVersionLabel, beforeVersionTime, versions);
// Return the new versions
return versions;
}
-
- /**
- * Gets the next version label
- */
- protected String peekNextVersionLabel(NodeRef nodeRef, int versionNumber, Map versionProperties)
- {
- Version version = this.versionService.getCurrentVersion(nodeRef);
- SerialVersionLabelPolicy policy = new SerialVersionLabelPolicy();
- return policy.calculateVersionLabel(ContentModel.TYPE_CMOBJECT, version, versionNumber, versionProperties);
- }
+
+ /**
+ * Gets the next version label
+ */
+ protected String peekNextVersionLabel(NodeRef nodeRef, Map versionProperties)
+ {
+ Version version = this.versionService.getCurrentVersion(nodeRef);
+ SerialVersionLabelPolicy policy = new SerialVersionLabelPolicy();
+ return policy.calculateVersionLabel(ContentModel.TYPE_CMOBJECT, version, versionProperties);
+ }
/**
* Checkd the validity of a new version
*
* @param beforeVersionTime the time snap shot before the version was created
- * @param expectedVersionNumber the expected version number
* @param newVersion the new version
* @param versionableNode the versioned node
*/
- protected void checkVersion(long beforeVersionTime, int expectedVersionNumber, String expectedVersionLabel, Version newVersion, NodeRef versionableNode)
+ protected void checkVersion(long beforeVersionTime, String expectedVersionLabel, Version newVersion, NodeRef versionableNode)
{
assertNotNull(newVersion);
- // Check the version label and version number
-
+ // Check the version label
assertEquals(
- "The expected version number was not used.",
- Integer.toString(expectedVersionNumber),
- newVersion.getVersionProperty(VersionBaseModel.PROP_VERSION_NUMBER).toString());
-
- assertEquals(
- "The expected version label was not used.",
- expectedVersionLabel,
- newVersion.getVersionLabel());
+ "The expected version label was not used.",
+ expectedVersionLabel,
+ newVersion.getVersionLabel());
// Check the created date
long afterVersionTime = System.currentTimeMillis();
- long createdDate = newVersion.getCreatedDate().getTime();
+ long createdDate = newVersion.getFrozenModifiedDate().getTime();
if (createdDate < beforeVersionTime || createdDate > afterVersionTime)
{
fail("The created date of the version is incorrect.");
}
// Check the creator
- assertEquals(AuthenticationUtil.getAdminUserName(), newVersion.getCreator());
+ assertEquals(AuthenticationUtil.getAdminUserName(), newVersion.getFrozenModifier());
// Check the metadata properties of the version
Map props = newVersion.getVersionProperties();
@@ -444,7 +432,7 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
}
else if (versionService.getVersionStoreReference().getIdentifier().equals(VersionModel.STORE_ID))
{
- // Deprecated V1 version store (eg. workspace://lightWeightVersionStore)
+ // Deprecated V1 version store (eg. workspace://lightWeightVersionStore)
assertEquals(
VersionModel.STORE_ID,
nodeRef.getStoreRef().getIdentifier());
@@ -455,9 +443,9 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
}
}
- protected void checkNewVersion(long beforeVersionTime, int expectedVersionNumber, String expectedVersionLabel, Version newVersion, NodeRef versionableNode)
+ protected void checkNewVersion(long beforeVersionTime, String expectedVersionLabel, Version newVersion, NodeRef versionableNode)
{
- checkVersion(beforeVersionTime, expectedVersionNumber, expectedVersionLabel, newVersion, versionableNode);
+ checkVersion(beforeVersionTime, expectedVersionLabel, newVersion, versionableNode);
// TODO: How do we check the frozen attributes ??
@@ -471,11 +459,10 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
/**
* Helper method to check the validity of the list of newly created versions.
*
- * @param expectedVersionNumber the expected version number that all the versions should have
* @param beforeVersionTime the time before the versions where created
* @param versions the collection of version objects
*/
- private void checkVersionCollection(int expectedVersionNumber, String expectedVersionLabel, long beforeVersionTime, Collection versions)
+ private void checkVersionCollection(String expectedVersionLabel, long beforeVersionTime, Collection versions)
{
for (Version version : versions)
{
@@ -485,7 +472,7 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
// Switch VersionStore depending on configured impl
if (versionService.getVersionStoreReference().getIdentifier().equals(Version2Model.STORE_ID))
{
- // V2 version store (eg. workspace://version2Store)
+ // V2 version store (eg. workspace://version2Store)
frozenNodeId = ((NodeRef)version.getVersionProperty(Version2Model.PROP_FROZEN_NODE_REF)).getId();
}
else if (versionService.getVersionStoreReference().getIdentifier().equals(VersionModel.STORE_ID))
@@ -501,19 +488,7 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
assertNotNull("The versionable node ref that relates to the frozen node id can not be found.", origionaNodeRef);
// Check the new version
- checkNewVersion(beforeVersionTime, expectedVersionNumber, expectedVersionLabel, version, origionaNodeRef);
+ checkNewVersion(beforeVersionTime, expectedVersionLabel, version, origionaNodeRef);
}
}
-
- /**
- * Returns the next version number without affecting the version counter.
- *
- * @return the next version number to be allocated
- */
- protected int peekNextVersionNumber()
- {
- StoreRef lwVersionStoreRef = this.versionService.getVersionStoreReference();
- return this.versionCounterDaoService.currentVersionNumber(lwVersionStoreRef) + 1;
- }
-
}
diff --git a/source/java/org/alfresco/repo/version/Version2Model.java b/source/java/org/alfresco/repo/version/Version2Model.java
index 58e369bd82..5df26fa521 100644
--- a/source/java/org/alfresco/repo/version/Version2Model.java
+++ b/source/java/org/alfresco/repo/version/Version2Model.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2008 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -64,7 +64,12 @@ public interface Version2Model extends VersionBaseModel
public static final String PROP_VERSION_DESCRIPTION = "versionDescription"; // maps from description
public static final QName PROP_QNAME_VERSION_LABEL = QName.createQName(NAMESPACE_URI, PROP_VERSION_LABEL);
+
+ /**
+ * @deprecated
+ */
public static final QName PROP_QNAME_VERSION_NUMBER = QName.createQName(NAMESPACE_URI, PROP_VERSION_NUMBER);
+
public static final QName PROP_QNAME_VERSION_DESCRIPTION = QName.createQName(NAMESPACE_URI, PROP_VERSION_DESCRIPTION);
// frozen sys:referenceable properties (x4)
diff --git a/source/java/org/alfresco/repo/version/Version2ServiceImpl.java b/source/java/org/alfresco/repo/version/Version2ServiceImpl.java
index e45b96bbcf..356ac63648 100644
--- a/source/java/org/alfresco/repo/version/Version2ServiceImpl.java
+++ b/source/java/org/alfresco/repo/version/Version2ServiceImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2009 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -55,9 +55,9 @@ import org.alfresco.service.cmr.version.VersionService;
import org.alfresco.service.cmr.version.VersionServiceException;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
-import org.springframework.extensions.surf.util.ParameterCheck;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.extensions.surf.util.ParameterCheck;
/**
* Version2 Service - implements version2Store (a lighter implementation of the lightWeightVersionStore)
@@ -123,15 +123,14 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
long startTime = System.currentTimeMillis();
- // Get the next version number
- int versionNumber = this.versionCounterService.nextVersionNumber(getVersionStoreReference());
-
+ int versionNumber = 0; // deprecated (unused)
+
// Create the version
Version version = createVersion(nodeRef, versionProperties, versionNumber);
if (logger.isDebugEnabled())
{
- logger.debug("created version (" + versionNumber + " - " + VersionUtil.convertNodeRef(version.getFrozenStateNodeRef()) + ") in " + (System.currentTimeMillis()-startTime) + " ms");
+ logger.debug("created version (" + VersionUtil.convertNodeRef(version.getFrozenStateNodeRef()) + ") in " + (System.currentTimeMillis()-startTime) + " ms");
}
return version;
@@ -159,9 +158,8 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
Collection result = new ArrayList(nodeRefs.size());
- // Get the next version number
- int versionNumber = this.versionCounterService.nextVersionNumber(getVersionStoreReference());
-
+ int versionNumber = 0; // deprecated (unused)
+
// Version each node in the list
for (NodeRef nodeRef : nodeRefs)
{
@@ -170,7 +168,7 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
if (logger.isDebugEnabled())
{
- logger.debug("created version list (" + versionNumber + " - " + getVersionStoreReference() + ") in "+ (System.currentTimeMillis()-startTime) +" ms (with " + nodeRefs.size() + " nodes)");
+ logger.debug("created version list (" + getVersionStoreReference() + ") in "+ (System.currentTimeMillis()-startTime) +" ms (with " + nodeRefs.size() + " nodes)");
}
return result;
@@ -294,7 +292,7 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
if (logger.isTraceEnabled())
{
- logger.trace("created version (" + versionNumber + " - " + getVersionStoreReference() + ") " + newVersionRef + " " + (System.currentTimeMillis()-startTime) +" ms");
+ logger.trace("created version (" + getVersionStoreReference() + ") " + newVersionRef + " " + (System.currentTimeMillis()-startTime) +" ms");
}
// Return the data object representing the newly created version
@@ -387,15 +385,15 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
{
Map result = new HashMap(10);
- // Set the version number
- result.put(Version2Model.PROP_QNAME_VERSION_NUMBER, versionNumber);
+ // deprecated (unused)
+ //result.put(Version2Model.PROP_QNAME_VERSION_NUMBER, versionNumber);
// Set the version label
result.put(Version2Model.PROP_QNAME_VERSION_LABEL, versionLabel);
// Set the version description (can be null)
result.put(Version2Model.PROP_QNAME_VERSION_DESCRIPTION, versionDescription);
-
+
// Set the versionable node store id
result.put(Version2Model.PROP_QNAME_FROZEN_NODE_REF, nodeRef);
@@ -604,9 +602,9 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
}
VersionHistory versionHistory = null;
-
- List versionsAssoc = this.dbNodeService.getChildAssocs(versionHistoryRef, Version2Model.CHILD_QNAME_VERSIONS, RegexQNamePattern.MATCH_ALL);
-
+
+ List versionsAssoc = this.dbNodeService.getChildAssocs(versionHistoryRef, Version2Model.CHILD_QNAME_VERSIONS, RegexQNamePattern.MATCH_ALL);
+
List versions = new ArrayList(versionsAssoc.size());
for (ChildAssociationRef versionAssoc : versionsAssoc)
@@ -619,7 +617,7 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
}
Collections.sort(versions, versionComparatorAsc);
-
+
// Build the version history object
boolean isRoot = true;
Version preceeding = null;
@@ -639,7 +637,7 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
return versionHistory;
}
-
+
/**
* Constructs the a version object to contain the version information from the version node ref.
*
@@ -658,7 +656,7 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
return null;
}
Map versionProperties = new HashMap();
-
+
// Get the standard node details and get the meta data
Map nodeProperties = this.dbNodeService.getProperties(versionRef);
@@ -692,7 +690,8 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
}
else if (key.equals(Version2Model.PROP_QNAME_VERSION_NUMBER))
{
- versionProperties.put(VersionBaseModel.PROP_VERSION_NUMBER, (Integer)value);
+ // deprecated (unused)
+ //versionProperties.put(VersionBaseModel.PROP_VERSION_NUMBER, (Integer)value);
}
else
{
@@ -1034,45 +1033,18 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
*/
private Version getHeadVersion(NodeRef nodeRef)
{
- Version version = null;
- StoreRef storeRef = nodeRef.getStoreRef();
-
NodeRef versionHistoryNodeRef = getVersionHistoryNodeRef(nodeRef);
+
+ Version headVersion = null;
if (versionHistoryNodeRef != null)
{
- List versionsAssoc = this.dbNodeService.getChildAssocs(versionHistoryNodeRef, Version2Model.CHILD_QNAME_VERSIONS, RegexQNamePattern.MATCH_ALL);
-
- ChildAssociationRef headVersionAssoc = null;
- int headVersionNumber = -1;
- for (ChildAssociationRef versionAssoc : versionsAssoc)
+ VersionHistory versionHistory = buildVersionHistory(versionHistoryNodeRef, nodeRef);
+ if (versionHistory != null)
{
- String localName = versionAssoc.getQName().getLocalName();
- if (localName.indexOf(Version2Model.CHILD_VERSIONS+"-") != -1) // TODO - could remove this belts-and-braces, should match correctly above !
- {
- int versionNumber = Integer.parseInt(localName.substring((Version2Model.CHILD_VERSIONS+"-").length()));
- if (versionNumber > headVersionNumber)
- {
- headVersionNumber = versionNumber;
- headVersionAssoc = versionAssoc;
- }
- }
+ headVersion = versionHistory.getHeadVersion();
}
-
- if (headVersionAssoc != null)
- {
- NodeRef versionNodeRef = headVersionAssoc.getChildRef();
- NodeRef versionedNodeRef = (NodeRef)this.dbNodeService.getProperty(
- versionNodeRef,
- QName.createQName(Version2Model.NAMESPACE_URI, Version2Model.PROP_FROZEN_NODE_REF));
- StoreRef versionStoreRef = versionedNodeRef.getStoreRef();
- if (storeRef.equals(versionStoreRef) == true)
- {
- version = getVersion(versionNodeRef);
- }
- }
}
-
- return version;
+ return headVersion;
}
/* (non-Javadoc)
diff --git a/source/java/org/alfresco/repo/version/VersionBaseModel.java b/source/java/org/alfresco/repo/version/VersionBaseModel.java
index c34c285086..46a058d7b7 100644
--- a/source/java/org/alfresco/repo/version/VersionBaseModel.java
+++ b/source/java/org/alfresco/repo/version/VersionBaseModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2008 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -46,6 +46,10 @@ public interface VersionBaseModel
public static final String PROP_CREATED_DATE = ContentModel.PROP_CREATED.getLocalName();
public static final String PROP_CREATOR = ContentModel.PROP_CREATOR.getLocalName();
public static final String PROP_VERSION_TYPE = "versionType";
+
+ /**
+ * @deprecated since 3.3
+ */
public static final String PROP_VERSION_NUMBER = "versionNumber";
/** The version store root aspect localname*/
diff --git a/source/java/org/alfresco/repo/version/VersionMigrator.java b/source/java/org/alfresco/repo/version/VersionMigrator.java
index 7e6e2454ea..0554a9d255 100644
--- a/source/java/org/alfresco/repo/version/VersionMigrator.java
+++ b/source/java/org/alfresco/repo/version/VersionMigrator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2009 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -201,7 +201,7 @@ public class VersionMigrator
// ALFCOM-2658
nodeProperties.put(ContentModel.PROP_NODE_UUID, frozenStateNodeRef.getId());
- int versionNumber = (Integer)dbNodeService.getProperty(VersionUtil.convertNodeRef(frozenStateNodeRef), VersionModel.PROP_QNAME_VERSION_NUMBER);
+ int versionNumber = 0;
// get oldVersion auditable properties (of the version node itself, rather than the live versioned node)
Date versionCreated = (Date)dbNodeService.getProperty(VersionUtil.convertNodeRef(frozenStateNodeRef), ContentModel.PROP_CREATED);
diff --git a/source/java/org/alfresco/repo/version/VersionMigratorTest.java b/source/java/org/alfresco/repo/version/VersionMigratorTest.java
index 15ba85ab2d..45a9e29476 100644
--- a/source/java/org/alfresco/repo/version/VersionMigratorTest.java
+++ b/source/java/org/alfresco/repo/version/VersionMigratorTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2009 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -35,13 +35,11 @@ import org.alfresco.repo.node.integrity.IntegrityChecker;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
-import org.alfresco.repo.version.common.counter.VersionCounterService;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
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.StoreRef;
import org.alfresco.service.cmr.version.Version;
import org.alfresco.service.cmr.version.VersionHistory;
import org.alfresco.service.namespace.NamespaceService;
@@ -65,7 +63,6 @@ public class VersionMigratorTest extends BaseVersionStoreTest
protected PolicyComponent policyComponent;
protected DictionaryService dictionaryService;
protected CheckOutCheckInService cociService;
- protected VersionCounterService versionCounterService;
protected IntegrityChecker integrityChecker;
public VersionMigratorTest()
@@ -84,14 +81,11 @@ public class VersionMigratorTest extends BaseVersionStoreTest
this.versionNodeService = (NodeService)applicationContext.getBean("versionNodeService"); // note: auto-switches between V1 and V2
this.cociService = (CheckOutCheckInService)applicationContext.getBean("CheckoutCheckinService");
- this.versionCounterService = (VersionCounterService)applicationContext.getBean("versionCounterService");
-
this.integrityChecker = (IntegrityChecker)applicationContext.getBean("integrityChecker");
// Version1Service is used to create the version nodes in Version1Store (workspace://lightWeightVersionStore)
version1Service.setDbNodeService(dbNodeService);
version1Service.setNodeService(dbNodeService);
- version1Service.setVersionCounterService(versionCounterDaoService);
version1Service.setPolicyComponent(policyComponent);
version1Service.setDictionaryService(dictionaryService);
version1Service.initialiseWithoutBind(); // TODO - temp - if use intialise, get: "More than one CalculateVersionLabelPolicy behaviour has been registered for the type {http://www.alfresco.org/model/content/1.0}content"
@@ -114,9 +108,8 @@ public class VersionMigratorTest extends BaseVersionStoreTest
logger.info("testMigrateOneVersion: versionedNodeRef = " + versionableNode);
- // Get the next version number
- int nextVersion = peekNextVersionNumber();
- String nextVersionLabel = peekNextVersionLabel(versionableNode, nextVersion, versionProperties);
+ // Get the next version label
+ String nextVersionLabel = peekNextVersionLabel(versionableNode, versionProperties);
// Snap-shot the node created date-time
Date beforeVersionDate = (Date)nodeService.getProperty(versionableNode, ContentModel.PROP_CREATED);
@@ -158,7 +151,7 @@ public class VersionMigratorTest extends BaseVersionStoreTest
// check new version - switch to new version service to do the check
super.setVersionService(version2Service);
- checkNewVersion(beforeVersionTime, nextVersion, nextVersionLabel, newVersion, versionableNode);
+ checkNewVersion(beforeVersionTime, nextVersionLabel, newVersion, versionableNode);
// get and compare new version details - - versionNodeService will retrieve these from the new version store
@@ -212,9 +205,8 @@ public class VersionMigratorTest extends BaseVersionStoreTest
NodeRef versionableNode = createNewVersionableNode();
- // Get the next version number, next version label and snapshot the date-time
- int nextVersion1 = peekNextVersionNumber();
- String nextVersionLabel1 = peekNextVersionLabel(versionableNode, nextVersion1, versionProperties);
+ // Get the next version label and snapshot the date-time
+ String nextVersionLabel1 = peekNextVersionLabel(versionableNode, versionProperties);
// Snap-shot the node created date-time
long beforeVersionTime1 = ((Date)nodeService.getProperty(versionableNode, ContentModel.PROP_CREATED)).getTime();
@@ -222,9 +214,8 @@ public class VersionMigratorTest extends BaseVersionStoreTest
Version version1 = createVersion(versionableNode);
logger.info(version1);
- // Get the next version number, next version label and snapshot the date-time
- int nextVersion2 = peekNextVersionNumber();
- String nextVersionLabel2 = peekNextVersionLabel(versionableNode, nextVersion2, versionProperties);
+ // Get the next version label and snapshot the date-time
+ String nextVersionLabel2 = peekNextVersionLabel(versionableNode, versionProperties);
// Snap-shot the node created date-time
long beforeVersionTime2 = ((Date)nodeService.getProperty(versionableNode, ContentModel.PROP_CREATED)).getTime();
@@ -232,9 +223,8 @@ public class VersionMigratorTest extends BaseVersionStoreTest
Version version2 = createVersion(versionableNode);
logger.info(version2);
- // Get the next version number, next version label and snapshot the date-time
- int nextVersion3 = peekNextVersionNumber();
- String nextVersionLabel3 = peekNextVersionLabel(versionableNode, nextVersion3, versionProperties);
+ // Get the next version label and snapshot the date-time
+ String nextVersionLabel3 = peekNextVersionLabel(versionableNode, versionProperties);
// Snap-shot the node created date-time
long beforeVersionTime3 = ((Date)nodeService.getProperty(versionableNode, ContentModel.PROP_CREATED)).getTime();
@@ -263,9 +253,9 @@ public class VersionMigratorTest extends BaseVersionStoreTest
Version[] newVersions = vh2.getAllVersions().toArray(new Version[]{});
- checkVersion(beforeVersionTime1, nextVersion1, nextVersionLabel1, newVersions[2], versionableNode);
- checkVersion(beforeVersionTime2, nextVersion2, nextVersionLabel2, newVersions[1], versionableNode);
- checkNewVersion(beforeVersionTime3, nextVersion3, nextVersionLabel3, newVersions[0], versionableNode);
+ checkVersion(beforeVersionTime1, nextVersionLabel1, newVersions[2], versionableNode);
+ checkVersion(beforeVersionTime2, nextVersionLabel2, newVersions[1], versionableNode);
+ checkNewVersion(beforeVersionTime3, nextVersionLabel3, newVersions[0], versionableNode);
// ALFCOM-2658
assertEquals(version1.getFrozenStateNodeRef().getId(), newVersions[2].getFrozenStateNodeRef().getId());
@@ -460,9 +450,6 @@ public class VersionMigratorTest extends BaseVersionStoreTest
version2Service.useDeprecatedV1 = true;
- // note: for testing only - not recommended !!!
- versionCounterService.setVersionNumber(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, VersionModel.STORE_ID), 100);
-
// Add the version aspect to the created node
nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null);
@@ -503,7 +490,7 @@ public class VersionMigratorTest extends BaseVersionStoreTest
//versionCounterService.setVersionNumber(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, Version2Model.STORE_ID), nextVersionNumber);
// to force the error: https://issues.alfresco.com/jira/browse/ETHREEOH-1540
- versionCounterService.setVersionNumber(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, Version2Model.STORE_ID), 0);
+ //versionCounterService.setVersionNumber(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, Version2Model.STORE_ID), 0);
NodeRef newVHNodeRef = versionMigrator.migrateVersionHistory(oldVHNodeRef, versionedNodeRef);
versionMigrator.v1DeleteVersionHistory(oldVHNodeRef);
diff --git a/source/java/org/alfresco/repo/version/VersionModel.java b/source/java/org/alfresco/repo/version/VersionModel.java
index 6c810fc730..6ead857e67 100644
--- a/source/java/org/alfresco/repo/version/VersionModel.java
+++ b/source/java/org/alfresco/repo/version/VersionModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2008 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -30,6 +30,8 @@ import org.alfresco.service.namespace.QName;
* Version1 Model Constants used by lightWeightVersionStore implementation
*
* @author Roy Wetherall
+ *
+ * NOTE: deprecated since 3.1 (migrate and useVersion2 Model)
*/
public interface VersionModel extends VersionBaseModel
{
@@ -66,21 +68,59 @@ public interface VersionModel extends VersionBaseModel
/**
* Version type properties and associations
*/
+
+ /**
+ * @deprecated since 3.1
+ */
public static final String PROP_FROZEN_NODE_ID = "frozenNodeId";
+ /**
+ * @deprecated since 3.1
+ */
public static final String PROP_FROZEN_NODE_STORE_PROTOCOL = "frozenNodeStoreProtocol";
+ /**
+ * @deprecated since 3.1
+ */
public static final String PROP_FROZEN_NODE_STORE_ID = "frozenNodeStoreId";
+ /**
+ * @deprecated since 3.1
+ */
public static final String PROP_FROZEN_NODE_TYPE = "frozenNodeType";
+ /**
+ * @deprecated since 3.1
+ */
public static final String PROP_FROZEN_ASPECTS = "frozenAspects";
public static final QName PROP_QNAME_VERSION_LABEL = QName.createQName(NAMESPACE_URI, PROP_VERSION_LABEL);
+
+ /**
+ * @deprecated since 3.3
+ */
public static final QName PROP_QNAME_VERSION_NUMBER = QName.createQName(NAMESPACE_URI, PROP_VERSION_NUMBER);
+ /**
+ * @deprecated since 3.1
+ */
public static final QName PROP_QNAME_FROZEN_NODE_ID = QName.createQName(NAMESPACE_URI, PROP_FROZEN_NODE_ID);
+ /**
+ * @deprecated since 3.1
+ */
public static final QName PROP_QNAME_FROZEN_NODE_TYPE = QName.createQName(NAMESPACE_URI, PROP_FROZEN_NODE_TYPE);
+ /**
+ * @deprecated since 3.1
+ */
public static final QName PROP_QNAME_FROZEN_NODE_STORE_PROTOCOL = QName.createQName(NAMESPACE_URI, PROP_FROZEN_NODE_STORE_PROTOCOL);
+ /**
+ * @deprecated since 3.1
+ */
public static final QName PROP_QNAME_FROZEN_NODE_STORE_ID = QName.createQName(NAMESPACE_URI, PROP_FROZEN_NODE_STORE_ID);
+ /**
+ * @deprecated since 3.1
+ */
public static final QName PROP_QNAME_FROZEN_ASPECTS = QName.createQName(NAMESPACE_URI, PROP_FROZEN_ASPECTS);
+ /**
+ * @deprecated since 3.1
+ */
public static final QName ASSOC_SUCCESSOR = QName.createQName(NAMESPACE_URI, "successor");
-
+
/**
* Version Meta Data Value type
*/
diff --git a/source/java/org/alfresco/repo/version/VersionServiceImpl.java b/source/java/org/alfresco/repo/version/VersionServiceImpl.java
index d6e3777be7..d5a6a169e5 100644
--- a/source/java/org/alfresco/repo/version/VersionServiceImpl.java
+++ b/source/java/org/alfresco/repo/version/VersionServiceImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2008 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -43,7 +43,6 @@ import org.alfresco.repo.version.common.AbstractVersionServiceImpl;
import org.alfresco.repo.version.common.VersionHistoryImpl;
import org.alfresco.repo.version.common.VersionImpl;
import org.alfresco.repo.version.common.VersionUtil;
-import org.alfresco.repo.version.common.counter.VersionCounterService;
import org.alfresco.repo.version.common.versionlabel.SerialVersionLabelPolicy;
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
@@ -63,14 +62,16 @@ import org.alfresco.service.cmr.version.VersionServiceException;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
-import org.springframework.extensions.surf.util.ParameterCheck;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.extensions.surf.util.ParameterCheck;
/**
* Version1 Service - implements lightWeightVersionStore
*
* @author Roy Wetheral
+ *
+ * NOTE: deprecated since 3.1 (migrate and use Version2 Service)
*/
public class VersionServiceImpl extends AbstractVersionServiceImpl implements VersionService, VersionModel
{
@@ -86,11 +87,6 @@ public class VersionServiceImpl extends AbstractVersionServiceImpl implements Ve
protected static final String MSGID_ERR_RESTORE_NO_VERSION = "version_service.err_restore_no_version";
protected static final String MSGID_ERR_REVERT_MISMATCH = "version_service.err_revert_mismatch";
- /**
- * The version counter service
- */
- protected VersionCounterService versionCounterService;
-
/**
* The db node service, used as the version store implementation
*/
@@ -123,15 +119,7 @@ public class VersionServiceImpl extends AbstractVersionServiceImpl implements Ve
{
this.searcher = searcher;
}
-
- /**
- * @param versionCounterService the version counter service
- */
- public void setVersionCounterService(VersionCounterService versionCounterService)
- {
- this.versionCounterService = versionCounterService;
- }
-
+
/**
* Set the policy behaviour filter
*
@@ -195,15 +183,14 @@ public class VersionServiceImpl extends AbstractVersionServiceImpl implements Ve
{
long startTime = System.currentTimeMillis();
- // Get the next version number
- int versionNumber = this.versionCounterService.nextVersionNumber(getVersionStoreReference());
-
+ int versionNumber = 0; // deprecated (unused)
+
// Create the version
Version version = createVersion(nodeRef, versionProperties, versionNumber);
if (logger.isDebugEnabled())
{
- logger.debug("created version (" + versionNumber + " - " + VersionUtil.convertNodeRef(version.getFrozenStateNodeRef()) + ") in " + (System.currentTimeMillis()-startTime) + " ms");
+ logger.debug("created version (" + VersionUtil.convertNodeRef(version.getFrozenStateNodeRef()) + ") in " + (System.currentTimeMillis()-startTime) + " ms");
}
return version;
@@ -222,9 +209,8 @@ public class VersionServiceImpl extends AbstractVersionServiceImpl implements Ve
{
long startTime = System.currentTimeMillis();
- // Get the next version number
- int versionNumber = this.versionCounterService.nextVersionNumber(getVersionStoreReference());
-
+ int versionNumber = 0; // deprecated (unused)
+
// Create the versions
Collection versions = createVersion(nodeRef, versionProperties, versionChildren, versionNumber);
@@ -232,7 +218,7 @@ public class VersionServiceImpl extends AbstractVersionServiceImpl implements Ve
{
Version[] versionsArray = versions.toArray(new Version[0]);
Version version = versionsArray[versionsArray.length -1]; // last item is the new parent version
- logger.debug("created version (" + versionNumber + " - " + VersionUtil.convertNodeRef(version.getFrozenStateNodeRef()) + ") in "+ (System.currentTimeMillis()-startTime) +" ms "+(versionChildren ? "(with " + (versions.size() - 1) + " children)" : ""));
+ logger.debug("created version (" + VersionUtil.convertNodeRef(version.getFrozenStateNodeRef()) + ") in "+ (System.currentTimeMillis()-startTime) +" ms "+(versionChildren ? "(with " + (versions.size() - 1) + " children)" : ""));
}
return versions;
@@ -297,10 +283,9 @@ public class VersionServiceImpl extends AbstractVersionServiceImpl implements Ve
long startTime = System.currentTimeMillis();
Collection result = new ArrayList(nodeRefs.size());
-
- // Get the next version number
- int versionNumber = this.versionCounterService.nextVersionNumber(getVersionStoreReference());
-
+
+ int versionNumber = 0; // deprecated (unused)
+
// Version each node in the list
for (NodeRef nodeRef : nodeRefs)
{
@@ -309,7 +294,7 @@ public class VersionServiceImpl extends AbstractVersionServiceImpl implements Ve
if (logger.isDebugEnabled())
{
- logger.debug("created version list (" + versionNumber + " - " + getVersionStoreReference() + ") in "+ (System.currentTimeMillis()-startTime) +" ms (with " + nodeRefs.size() + " nodes)");
+ logger.debug("created version list (" + getVersionStoreReference() + ") in "+ (System.currentTimeMillis()-startTime) +" ms (with " + nodeRefs.size() + " nodes)");
}
return result;
@@ -433,7 +418,7 @@ public class VersionServiceImpl extends AbstractVersionServiceImpl implements Ve
if (logger.isTraceEnabled())
{
- logger.trace("created Version (" + versionNumber + " - " + getVersionStoreReference() + ") " + nodeRef + " in " + (System.currentTimeMillis()-startTime) +" ms");
+ logger.trace("created Version (" + getVersionStoreReference() + ") " + nodeRef + " in " + (System.currentTimeMillis()-startTime) +" ms");
}
// Return the data object representing the newly created version
@@ -514,8 +499,8 @@ public class VersionServiceImpl extends AbstractVersionServiceImpl implements Ve
{
Map result = new HashMap(10);
- // Set the version number for the new version
- result.put(VersionModel.PROP_QNAME_VERSION_NUMBER, Integer.toString(versionNumber));
+ // deprecated (unused)
+ //result.put(VersionModel.PROP_QNAME_VERSION_NUMBER, Integer.toString(versionNumber));
// Set the versionable node id
result.put(VersionModel.PROP_QNAME_FROZEN_NODE_ID, nodeRef.getId());
diff --git a/source/java/org/alfresco/repo/version/VersionServiceImplTest.java b/source/java/org/alfresco/repo/version/VersionServiceImplTest.java
index 0bdd9ee530..36ae8324cb 100644
--- a/source/java/org/alfresco/repo/version/VersionServiceImplTest.java
+++ b/source/java/org/alfresco/repo/version/VersionServiceImplTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2009 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -149,10 +149,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
NodeRef versionableNode = createNewVersionableNode();
// Snap shot data
- int expectedVersionNumber = peekNextVersionNumber();
- String expectedVersionLabel = peekNextVersionLabel(versionableNode, expectedVersionNumber, versionProperties);
-
- // Snap-shot the node created date-time
+ String expectedVersionLabel = peekNextVersionLabel(versionableNode, versionProperties);
+
+ // Snap-shot the node created date-time
long beforeVersionTime = ((Date)nodeService.getProperty(versionableNode, ContentModel.PROP_CREATED)).getTime();
// Version the node and its children
@@ -162,7 +161,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
true);
// Check the returned versions are correct
- CheckVersionCollection(expectedVersionNumber, expectedVersionLabel, beforeVersionTime, versions);
+ CheckVersionCollection(expectedVersionLabel, beforeVersionTime, versions);
// TODO check the version history is correct
}
@@ -175,10 +174,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
NodeRef versionableNode = createNewVersionableNode();
// Snap shot data
- int expectedVersionNumber = peekNextVersionNumber();
- String expectedVersionLabel = peekNextVersionLabel(versionableNode, expectedVersionNumber, versionProperties);
-
- // Snap-shot the node created date-time
+ String expectedVersionLabel = peekNextVersionLabel(versionableNode, versionProperties);
+
+ // Snap-shot the node created date-time
long beforeVersionTime = ((Date)nodeService.getProperty(versionableNode, ContentModel.PROP_CREATED)).getTime();
// Version the list of nodes created
@@ -187,19 +185,18 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
this.versionProperties);
// Check the returned versions are correct
- CheckVersionCollection(expectedVersionNumber, expectedVersionLabel, beforeVersionTime, versions);
-
+ CheckVersionCollection(expectedVersionLabel, beforeVersionTime, versions);
+
// TODO check the version histories
}
/**
* Helper method to check the validity of the list of newly created versions.
*
- * @param expectedVersionNumber the expected version number that all the versions should have
* @param beforeVersionTime the time before the versions where created
* @param versions the collection of version objects
*/
- private void CheckVersionCollection(int expectedVersionNumber, String expectedVersionLabel, long beforeVersionTime, Collection versions)
+ private void CheckVersionCollection(String expectedVersionLabel, long beforeVersionTime, Collection versions)
{
for (Version version : versions)
{
@@ -225,7 +222,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
assertNotNull("The versionable node ref that relates to the frozen node id can not be found.", originalNodeRef);
// Check the new version
- checkNewVersion(beforeVersionTime, expectedVersionNumber, expectedVersionLabel, version, originalNodeRef);
+ checkNewVersion(beforeVersionTime, expectedVersionLabel, version, originalNodeRef);
}
}
@@ -697,7 +694,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
// Check that the initial version has not been created
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
- assertEquals(1, versionHistory.getAllVersions().size());
+ assertEquals(1, versionHistory.getAllVersions().size());
// Add some content
ContentWriter contentWriter = contentService.getWriter(versionableNode, ContentModel.PROP_CONTENT, true);
diff --git a/source/java/org/alfresco/repo/version/VersionTestSuite.java b/source/java/org/alfresco/repo/version/VersionTestSuite.java
index c75087f948..a7bc603433 100644
--- a/source/java/org/alfresco/repo/version/VersionTestSuite.java
+++ b/source/java/org/alfresco/repo/version/VersionTestSuite.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -29,7 +29,6 @@ import junit.framework.TestSuite;
import org.alfresco.repo.version.common.VersionHistoryImplTest;
import org.alfresco.repo.version.common.VersionImplTest;
-import org.alfresco.repo.version.common.counter.VersionCounterServiceTest;
import org.alfresco.repo.version.common.versionlabel.SerialVersionLabelPolicyTest;
/**
@@ -50,7 +49,6 @@ public class VersionTestSuite extends TestSuite
suite.addTestSuite(VersionImplTest.class);
suite.addTestSuite(VersionHistoryImplTest.class);
suite.addTestSuite(SerialVersionLabelPolicyTest.class);
- suite.addTestSuite(VersionCounterServiceTest.class);
suite.addTestSuite(VersionServiceImplTest.class);
suite.addTestSuite(NodeServiceImplTest.class);
suite.addTestSuite(ContentServiceImplTest.class);
diff --git a/source/java/org/alfresco/repo/version/common/VersionHistoryImpl.java b/source/java/org/alfresco/repo/version/common/VersionHistoryImpl.java
index 3a0ccf1e60..62fd441308 100644
--- a/source/java/org/alfresco/repo/version/common/VersionHistoryImpl.java
+++ b/source/java/org/alfresco/repo/version/common/VersionHistoryImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2009 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -53,7 +53,7 @@ public class VersionHistoryImpl implements VersionHistory
/*
* Error message(s)
*/
- private static final String ERR_MSG = "The root version must be specified when creating a version history object.";
+ private static final String ERR_MSG = "The root version must be specified when creating a version history object.";
/*
* Field is left here to aid in detection of old serialized versions
@@ -101,11 +101,11 @@ public class VersionHistoryImpl implements VersionHistory
this.versionsByLabel = new HashMap();
this.rootVersion = rootVersion;
- addVersion(rootVersion, null);
+ addVersion(rootVersion, null);
}
/**
- * Gets the root (or initial) version of the version history.
+ * Gets the root (initial / least recent) version of the version history.
*
* @return the root version
*/
@@ -114,6 +114,19 @@ public class VersionHistoryImpl implements VersionHistory
return this.rootVersion;
}
+ /**
+ * Gets the head (current / most recent) version of the version history.
+ *
+ * @return the head version
+ */
+ public Version getHeadVersion()
+ {
+ Collection versions = versionsByLabel.values();
+ List sortedVersions = new ArrayList(versions);
+ Collections.sort(sortedVersions, versionComparatorDesc);
+ return sortedVersions.get(0);
+ }
+
/**
* Gets a collection containing all the versions within the
* version history.
@@ -126,7 +139,7 @@ public class VersionHistoryImpl implements VersionHistory
{
Collection versions = versionsByLabel.values();
List sortedVersions = new ArrayList(versions);
- Collections.sort(sortedVersions, versionComparatorDesc);
+ Collections.sort(sortedVersions, versionComparatorDesc);
return sortedVersions;
}
diff --git a/source/java/org/alfresco/repo/version/common/VersionUtil.java b/source/java/org/alfresco/repo/version/common/VersionUtil.java
index 4b2a44061d..c3ac9e0a3f 100644
--- a/source/java/org/alfresco/repo/version/common/VersionUtil.java
+++ b/source/java/org/alfresco/repo/version/common/VersionUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2008 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -52,14 +52,14 @@ public class VersionUtil
* Reserved property names
*/
public static final String[] RESERVED_PROPERTY_NAMES = new String[]{
- VersionModel.PROP_FROZEN_NODE_ID, // deprecated
- VersionModel.PROP_FROZEN_NODE_STORE_ID, // deprecated
- VersionModel.PROP_FROZEN_NODE_STORE_PROTOCOL, // deprecated
- VersionModel.PROP_FROZEN_NODE_TYPE, // deprecated
- VersionModel.PROP_FROZEN_ASPECTS, // deprecated
+ VersionModel.PROP_FROZEN_NODE_ID, // deprecated (since 3.1)
+ VersionModel.PROP_FROZEN_NODE_STORE_ID, // deprecated (since 3.1)
+ VersionModel.PROP_FROZEN_NODE_STORE_PROTOCOL, // deprecated (since 3.1)
+ VersionModel.PROP_FROZEN_NODE_TYPE, // deprecated (since 3.1)
+ VersionModel.PROP_FROZEN_ASPECTS, // deprecated (since 3.1)
VersionBaseModel.PROP_CREATED_DATE,
VersionBaseModel.PROP_VERSION_LABEL,
- VersionBaseModel.PROP_VERSION_NUMBER,
+ VersionBaseModel.PROP_VERSION_NUMBER, // deprecated (since 3.3)
VersionBaseModel.PROP_VERSION_DESCRIPTION,
Version2Model.PROP_FROZEN_NODE_DBID,
Version2Model.PROP_FROZEN_CREATED,
diff --git a/source/java/org/alfresco/repo/version/common/counter/VersionCounterService.java b/source/java/org/alfresco/repo/version/common/counter/VersionCounterService.java
deleted file mode 100644
index 2ee6b59e9b..0000000000
--- a/source/java/org/alfresco/repo/version/common/counter/VersionCounterService.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program 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 General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.version.common.counter;
-
-import org.alfresco.service.cmr.repository.StoreRef;
-import org.alfresco.service.namespace.QName;
-
-/**
- * Version counter service interface.
- *
- * @author Roy Wetherall
- */
-public interface VersionCounterService
-{
- /**
- * Get the next available version number for the specified store.
- *
- * @param storeRef the store reference
- * @return the next version number
- */
- public int nextVersionNumber(StoreRef storeRef);
-
- /**
- * Gets the current version number for the specified store.
- *
- * @param storeRef the store reference
- * @return the current versio number
- */
- public int currentVersionNumber(StoreRef storeRef);
-
- /**
- * Resets the version number for a the specified store.
- *
- * WARNING: calling this method will completely reset the current
- * version count for the specified store and cannot be undone.
- *
- * @param storeRef the store reference
- */
- public void resetVersionNumber(StoreRef storeRef);
-
- /**
- * Sets the version number for a specified store.
- *
- * WARNING: calling this method will completely reset the current
- * version count for the specified store and cannot be undone.
- *
- * @param storeRef the store reference
- * @param versionCount the new version count
- */
- public void setVersionNumber(StoreRef storeRef, int versionCount);
-
-}
diff --git a/source/java/org/alfresco/repo/version/common/counter/VersionCounterServiceTest.java b/source/java/org/alfresco/repo/version/common/counter/VersionCounterServiceTest.java
deleted file mode 100644
index 925d7b68c5..0000000000
--- a/source/java/org/alfresco/repo/version/common/counter/VersionCounterServiceTest.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program 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 General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.version.common.counter;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.transaction.UserTransaction;
-
-import junit.framework.TestCase;
-
-import org.alfresco.repo.security.authentication.AuthenticationComponent;
-import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
-import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.cmr.repository.StoreRef;
-import org.alfresco.service.transaction.TransactionService;
-import org.alfresco.util.ApplicationContextHelper;
-import org.springframework.context.ApplicationContext;
-
-/**
- * @author Roy Wetherall
- */
-public class VersionCounterServiceTest extends TestCase
-{
- private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
-
- private StoreRef storeRef1;
- private StoreRef storeRef2;
-
- private TransactionService transactionService;
- private NodeService nodeService;
- private VersionCounterService counter;
-
- @Override
- public void setUp() throws Exception
- {
- ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
- transactionService = serviceRegistry.getTransactionService();
- nodeService = serviceRegistry.getNodeService();
- counter = (VersionCounterService) ctx.getBean("versionCounterService");
-
- // authenticate
- AuthenticationComponent auth = (AuthenticationComponent) ctx.getBean("authenticationComponent");
- auth.setSystemUserAsCurrentUser();
-
- storeRef1 = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "test1_" + System.currentTimeMillis());
- storeRef2 = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "test2_" + System.currentTimeMillis());
- }
-
- public void testSetUp() throws Exception
- {
- assertNotNull(transactionService);
- assertNotNull(counter);
- }
-
- /**
- * Test nextVersionNumber
- */
- public void testNextVersionNumber() throws Exception
- {
- UserTransaction txn = transactionService.getUserTransaction();
- try
- {
- txn.begin();
-
- int store1Version0 = counter.nextVersionNumber(storeRef1);
- assertEquals(1, store1Version0);
-
- int store1Version1 = counter.nextVersionNumber(storeRef1);
- assertEquals(2, store1Version1);
-
- int store2Version0 = counter.nextVersionNumber(storeRef2);
- assertEquals(1, store2Version0);
-
- int store1Version2 = counter.nextVersionNumber(storeRef1);
- assertEquals(3, store1Version2);
-
- int store2Version1 = counter.nextVersionNumber(storeRef2);
- assertEquals(2, store2Version1);
-
- int store1Current = counter.currentVersionNumber(storeRef1);
- assertEquals(3, store1Current);
-
- int store2Current = counter.currentVersionNumber(storeRef2);
- assertEquals(2, store2Current);
-
- // Need to clean-up since the version counter works in its own transaction
- counter.resetVersionNumber(storeRef1);
- counter.resetVersionNumber(storeRef2);
- }
- finally
- {
- try { txn.rollback(); } catch (Throwable e) {}
- }
- }
-
- public void testConcurrentVersionNumber() throws Throwable
- {
- counter.currentVersionNumber(storeRef1);
- VersionCounterThread[] threads = new VersionCounterThread[threadCount];
- for (int i = 0; i < threadCount; i++)
- {
- threads[i] = new VersionCounterThread("VersionCounterThread_" + i);
- // start the thread
- threads[i].start();
- }
-
- // wait for the threads to all be done (or 10 seconds has passed)
- endSignal.await(10, TimeUnit.SECONDS);
-
- // check for exceptions
- for (VersionCounterThread thread : threads)
- {
- if (thread.error != null)
- {
- throw thread.error;
- }
- }
- }
-
- private int threadCount = 5;
- private CountDownLatch startSignal = new CountDownLatch(threadCount);
- private CountDownLatch endSignal = new CountDownLatch(threadCount);
-
- private class VersionCounterThread extends Thread
- {
- private Throwable error = new RuntimeException("Execution didn't complete");
- public VersionCounterThread(String name)
- {
- super(name);
- }
-
- @Override
- public void run()
- {
- RetryingTransactionCallback