1 17 package org.alfresco.repo.version.common; 18 19 import java.io.Serializable ; 20 import java.util.Date ; 21 import java.util.Map ; 22 23 import org.alfresco.repo.version.VersionModel; 24 import org.alfresco.service.cmr.repository.NodeRef; 25 import org.alfresco.service.cmr.repository.StoreRef; 26 import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; 27 import org.alfresco.service.cmr.repository.datatype.TypeConverter; 28 import org.alfresco.service.cmr.version.Version; 29 import org.alfresco.service.cmr.version.VersionServiceException; 30 import org.alfresco.service.cmr.version.VersionType; 31 32 33 40 public class VersionImpl implements Version 41 { 42 45 private static final long serialVersionUID = 3257567304324888881L; 46 47 50 private static final String ERR_NO_NODE_REF = "A valid node reference must be supplied when creating a verison."; 51 52 55 private Map <String , Serializable > versionProperties = null; 56 57 60 private NodeRef nodeRef = null; 61 62 68 public VersionImpl( 69 Map <String , Serializable > versionProperties, 70 NodeRef nodeRef) 71 { 72 if (nodeRef == null) 73 { 74 throw new VersionServiceException(VersionImpl.ERR_NO_NODE_REF); 76 } 77 78 this.versionProperties = versionProperties; 79 this.nodeRef = nodeRef; 80 } 81 82 83 88 public Date getCreatedDate() 89 { 90 return (Date )this.versionProperties.get(VersionModel.PROP_CREATED_DATE); 91 } 92 93 public String getCreator() 94 { 95 return (String )this.versionProperties.get(VersionModel.PROP_CREATOR); 96 } 97 98 103 public String getVersionLabel() 104 { 105 return (String )this.versionProperties.get(VersionModel.PROP_VERSION_LABEL); 106 } 107 108 113 public VersionType getVersionType() 114 { 115 return (VersionType)this.versionProperties.get(VersionModel.PROP_VERSION_TYPE); 116 } 117 118 123 public String getDescription() 124 { 125 return (String )this.versionProperties.get(PROP_DESCRIPTION); 126 } 127 128 131 public Map <String , Serializable > getVersionProperties() 132 { 133 return this.versionProperties; 134 } 135 136 139 public Serializable getVersionProperty(String name) 140 { 141 Serializable result = null; 142 if (this.versionProperties != null) 143 { 144 result = this.versionProperties.get(name); 145 } 146 return result; 147 } 148 149 152 public NodeRef getVersionedNodeRef() 153 { 154 String storeProtocol = (String )this.versionProperties.get(VersionModel.PROP_FROZEN_NODE_STORE_PROTOCOL); 155 String storeId = (String )this.versionProperties.get(VersionModel.PROP_FROZEN_NODE_STORE_ID); 156 String nodeId = (String )this.versionProperties.get(VersionModel.PROP_FROZEN_NODE_ID); 157 return new NodeRef(new StoreRef(storeProtocol, storeId), nodeId); 158 } 159 160 163 public NodeRef getFrozenStateNodeRef() 164 { 165 return this.nodeRef; 166 } 167 168 171 static 172 { 173 DefaultTypeConverter.INSTANCE.addConverter( 174 String .class, 175 VersionType.class, 176 new TypeConverter.Converter<String , VersionType>() 177 { 178 public VersionType convert(String source) 179 { 180 return VersionType.valueOf(source); 181 } 182 183 }); 184 185 DefaultTypeConverter.INSTANCE.addConverter( 186 VersionType.class, 187 String .class, 188 new TypeConverter.Converter<VersionType, String >() 189 { 190 public String convert(VersionType source) 191 { 192 return source.toString(); 193 } 194 195 }); 196 } 197 } 198 | Popular Tags |