mirror of
				https://github.com/Alfresco/alfresco-community-repo.git
				synced 2025-10-29 15:21:53 +00:00 
			
		
		
		
	13625: Fix ETHREEOH-1644
   13634: Merged V2.2 to V3.1
      13632: Preparation for fix of ETHREEOH-1663: ML Document Editions Broken by Upgrade to 3.1
   13636: Fixed ETHREEOH-1663: ML Document Editions Broken by Upgrade to 3.1
   13638: Fixed ETHREEOH-1665: Copy/pasting a Specialised Folder changes the assoc qname
   13639: Fixed ETHREEOH-1663: ML Document Editions Broken by Upgrade to 3.1
   13640: Fixed ETHREEOH-1672: Manage Multilingual Content JSP breaks when viewing all Related Content
   13641: Fixed ETHREEOH-1657: Manage Multilingual Content fails with NPE when document was previously versionable
   13774: Fix for ETHREEOH-1629
   13775: Fix for ETHREEOH-1645
   13784: SchemaBootstrap now auto-generates a mostly-canonical schema description on new DB and on upgrades
   13804: Added option to finish schema bootstrap, dump schema structure and exit
   13807: Further pretty formatting of schema dump
   ___________________________________________________________________
   Modified: svn:mergeinfo
      Merged /alfresco/BRANCHES/V2.2:r13632
      Merged /alfresco/BRANCHES/V3.1:r13625,13634,13636,13638-13641,13774-13775,13784,13804,13807
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13912 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
		
	
		
			
				
	
	
		
			221 lines
		
	
	
		
			7.3 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			221 lines
		
	
	
		
			7.3 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| /*
 | |
|  * 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.version.common;
 | |
| 
 | |
| import java.io.Serializable;
 | |
| import java.util.Date;
 | |
| import java.util.Map;
 | |
| 
 | |
| import org.alfresco.repo.version.Version2Model;
 | |
| import org.alfresco.repo.version.VersionBaseModel;
 | |
| import org.alfresco.repo.version.VersionModel;
 | |
| import org.alfresco.service.cmr.repository.NodeRef;
 | |
| import org.alfresco.service.cmr.repository.StoreRef;
 | |
| import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
 | |
| import org.alfresco.service.cmr.repository.datatype.TypeConverter;
 | |
| import org.alfresco.service.cmr.version.Version;
 | |
| import org.alfresco.service.cmr.version.VersionServiceException;
 | |
| import org.alfresco.service.cmr.version.VersionType;
 | |
| 
 | |
| 
 | |
| /**
 | |
|  * Version class implementation.
 | |
|  * 
 | |
|  * Used to represent the data about a version stored in a version store.
 | |
|  * 
 | |
|  * @author Roy Wetherall
 | |
|  */
 | |
| 
 | |
| public class VersionImpl implements Version
 | |
| {
 | |
|     /**
 | |
|      * Serial version UID
 | |
|      */
 | |
|     private static final long serialVersionUID = 3257567304324888881L;
 | |
|     
 | |
|     /**
 | |
|      * Error message(s)
 | |
|      */
 | |
|     private static final String ERR_NO_NODE_REF = "A valid node reference must be supplied when creating a verison.";       
 | |
|     
 | |
|     /**
 | |
|      * The properties of the version
 | |
|      */
 | |
|     private Map<String, Serializable> versionProperties = null;
 | |
|     
 | |
|     /**
 | |
|      * The node reference that represents the frozen state of the versioned object
 | |
|      */
 | |
|     private NodeRef nodeRef = null;        
 | |
|     
 | |
|     /**
 | |
|      * Constructor that initialises the state of the version object.
 | |
|      * 
 | |
|      * @param  versionProperties  the version properties
 | |
|      * @param  nodeRef            the forzen state node reference
 | |
|      */
 | |
|     public VersionImpl(
 | |
|             Map<String, Serializable> versionProperties, 
 | |
|             NodeRef nodeRef)
 | |
|     {
 | |
|         if (nodeRef == null)
 | |
|         {
 | |
|             // Exception - a node ref must be specified
 | |
|             throw new VersionServiceException(VersionImpl.ERR_NO_NODE_REF);
 | |
|         }
 | |
|         
 | |
|         this.versionProperties = versionProperties;
 | |
|         this.nodeRef = nodeRef;        
 | |
|     }
 | |
|     
 | |
| 
 | |
|     @Override
 | |
|     public String toString()
 | |
|     {
 | |
|         return versionProperties.toString();
 | |
|     }
 | |
|     
 | |
|     public Date getFrozenModifiedDate()
 | |
|     {
 | |
|         Date modifiedDate = (Date)this.versionProperties.get(Version2Model.PROP_FROZEN_MODIFIED);
 | |
|         if (modifiedDate == null)
 | |
|         {
 | |
|             // Assume deprecated V1 version store
 | |
|             modifiedDate = (Date)this.versionProperties.get(VersionBaseModel.PROP_CREATED_DATE);
 | |
|         }
 | |
|         return modifiedDate;
 | |
|     }
 | |
|     
 | |
|     public String getFrozenModifier()
 | |
|     {
 | |
|         String modifier = (String)this.versionProperties.get(Version2Model.PROP_FROZEN_MODIFIER);
 | |
|         if (modifier == null)
 | |
|         {
 | |
|             // Assume deprecated V1 version store
 | |
|             modifier = (String)this.versionProperties.get(VersionBaseModel.PROP_CREATOR);
 | |
|         }
 | |
|         return modifier;
 | |
|     }
 | |
|     
 | |
|     public Date getCreatedDate()
 | |
|     {
 | |
|         // note: internal version node created date can be retrieved via standard node service
 | |
|         return getFrozenModifiedDate();
 | |
|     }
 | |
|     
 | |
|     public String getCreator()
 | |
|     {
 | |
|         // note: internal version node creator can be retrieved via standard node service
 | |
|         return getFrozenModifier();
 | |
|     }
 | |
|     
 | |
|     public String getVersionLabel()
 | |
|     {
 | |
|         return (String)this.versionProperties.get(VersionBaseModel.PROP_VERSION_LABEL);
 | |
|     }    
 | |
|     
 | |
|     public VersionType getVersionType()
 | |
|     {
 | |
|         return (VersionType)this.versionProperties.get(VersionBaseModel.PROP_VERSION_TYPE);
 | |
|     }
 | |
|     
 | |
|     public String getDescription()
 | |
|     {
 | |
|         return (String)this.versionProperties.get(Version.PROP_DESCRIPTION);
 | |
|     }
 | |
|     
 | |
|     public Map<String, Serializable> getVersionProperties()
 | |
|     {
 | |
|         return this.versionProperties;
 | |
|     }
 | |
|     
 | |
|     public Serializable getVersionProperty(String name)
 | |
|     {
 | |
|         Serializable result = null;
 | |
|         if (this.versionProperties != null)
 | |
|         {
 | |
|             result = this.versionProperties.get(name);
 | |
|         }
 | |
|         return result;
 | |
|     }
 | |
|     
 | |
|     public NodeRef getVersionedNodeRef()
 | |
|     {
 | |
|         NodeRef versionedNodeRef = null;
 | |
|         
 | |
|         // Switch VersionStore depending on configured impl
 | |
|         if (nodeRef.getStoreRef().getIdentifier().equals(Version2Model.STORE_ID))
 | |
|         {
 | |
|             // V2 version store (eg. workspace://version2Store)
 | |
|             versionedNodeRef = (NodeRef)this.versionProperties.get(Version2Model.PROP_FROZEN_NODE_REF);
 | |
|         } 
 | |
|         else if (nodeRef.getStoreRef().getIdentifier().equals(VersionModel.STORE_ID))
 | |
|         {
 | |
|             // Deprecated V1 version store (eg. workspace://lightWeightVersionStore)
 | |
|             String storeProtocol = (String)this.versionProperties.get(VersionModel.PROP_FROZEN_NODE_STORE_PROTOCOL);
 | |
|             String storeId = (String)this.versionProperties.get(VersionModel.PROP_FROZEN_NODE_STORE_ID);
 | |
|             String nodeId = (String)this.versionProperties.get(VersionModel.PROP_FROZEN_NODE_ID);
 | |
|             versionedNodeRef = new NodeRef(new StoreRef(storeProtocol, storeId), nodeId);
 | |
|         }
 | |
|         
 | |
|         return versionedNodeRef;
 | |
|     }
 | |
|     
 | |
|     public NodeRef getFrozenStateNodeRef()
 | |
|     {
 | |
|         return this.nodeRef;
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Static block to register the version type converters
 | |
|      */
 | |
|     static
 | |
|     {
 | |
|         DefaultTypeConverter.INSTANCE.addConverter(
 | |
|                 String.class, 
 | |
|                 VersionType.class, 
 | |
|                 new TypeConverter.Converter<String, VersionType>()
 | |
|                 {
 | |
|                     public VersionType convert(String source)
 | |
|                     {
 | |
|                         return VersionType.valueOf(source);
 | |
|                     }
 | |
|         
 | |
|                 });
 | |
|         
 | |
|         DefaultTypeConverter.INSTANCE.addConverter(
 | |
|                 VersionType.class,
 | |
|                 String.class,
 | |
|                 new TypeConverter.Converter<VersionType, String>()
 | |
|                 {
 | |
|                     public String convert(VersionType source)
 | |
|                     {
 | |
|                         return source.toString();
 | |
|                     }
 | |
|         
 | |
|                 });
 | |
|     }
 | |
|  }
 |