Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 19 package org.openharmonise.vfs; 20 21 import java.util.ArrayList ; 22 import java.util.Iterator ; 23 import java.util.List ; 24 25 import org.openharmonise.vfs.event.*; 26 import org.openharmonise.vfs.status.*; 27 28 29 30 38 public class VersionedVirtualFile extends VirtualFile { 39 40 43 private String m_sPendingVersionPath = null; 44 45 48 private ArrayList m_aHistoricalVersionPaths = new ArrayList (); 49 50 53 private boolean m_bHistoryPopulated = false; 54 55 58 private String m_sLiveVersionPath = null; 59 60 65 public VersionedVirtualFile(String sFullPath) { 66 super(); 67 this.setFullPath(sFullPath); 68 this.setVersionable(true); 69 } 70 71 77 public boolean isHistoryPopulated() { 78 return this.m_bHistoryPopulated; 79 } 80 81 84 public VersionedVirtualFile() { 85 super(); 86 this.setVersionable(true); 87 } 88 89 95 public boolean hasPendingVersion() { 96 return this.m_sPendingVersionPath!=null; 97 } 98 99 105 public String getPendingVersionPath() { 106 if(this.m_sPendingVersionPath!=null) { 107 ((VersionedVirtualFile)this.m_vfs.getVirtualFile(this.m_sPendingVersionPath).getResource()).setLiveVersionPath(this.getFullPath()); 108 ((VersionedVirtualFile)this.m_vfs.getVirtualFile(this.m_sPendingVersionPath).getResource()).setState(VirtualFile.STATE_PENDING); 109 } 110 return this.m_sPendingVersionPath; 111 } 112 113 118 protected void setPendingVersionPath(String sPath) { 119 this.m_sPendingVersionPath = sPath; 120 } 121 122 127 protected void setLiveVersionPath(String sPath) { 128 this.m_sLiveVersionPath = sPath; 129 } 130 131 136 public String getLiveVersionPath() { 137 return this.m_sLiveVersionPath; 138 } 139 140 148 public String getLogicalPath() { 149 if(this.getState()==VirtualFile.STATE_PENDING) { 150 if(this.getLiveVersionPath()!=null) { 151 return this.getLiveVersionPath(); 152 } else { 153 return this.getFullPath(); 154 } 155 } else if(this.getState()==VirtualFile.STATE_HISTORICAL) { 156 return this.getLiveVersionPath(); 157 } else { 158 return this.getFullPath(); 159 } 160 } 161 162 168 public List getHistoricalVersions() { 169 if(!this.m_bHistoryPopulated) { 170 ((AbstractVersioningVFS)this.m_vfs).fullyPopulateFileHistory(this); 171 } 172 Iterator iterator = this.m_aHistoricalVersionPaths.iterator(); 173 while (iterator.hasNext()) { 174 String element = ((String ) iterator.next()); 175 if(element!=null) { 176 VersionedVirtualFile vfHistorical = (VersionedVirtualFile) this.m_vfs.getVirtualFile(element).getResource(); 177 vfHistorical.setLiveVersionPath(this.getFullPath()); 178 vfHistorical.setState(VirtualFile.STATE_HISTORICAL); 179 } 180 } 181 return (List ) this.m_aHistoricalVersionPaths.clone(); 182 } 183 184 190 protected void setHistoryPopulated(boolean bHistoryPopulated) { 191 this.m_bHistoryPopulated = bHistoryPopulated; 192 } 193 194 199 protected void addHistoricalVersion(String sPath) { 200 if(!this.m_aHistoricalVersionPaths.contains(sPath)) { 201 this.m_aHistoricalVersionPaths.add(sPath); 202 } 203 } 204 205 210 protected void removeHistoricalVersion(String sPath) { 211 this.m_aHistoricalVersionPaths.remove(sPath); 212 } 213 214 220 public StatusData reactivate() { 221 VFSStatus retnStatus = new VFSStatus(); 222 retnStatus.setMethodName(VirtualFile.METHOD_CHECKOUT); 223 224 StatusData vfsStatus = ((AbstractVersioningVFS)this.m_vfs).reactivateVersion(this.getFullPath()); 225 retnStatus.addStatusData(vfsStatus); 226 227 return retnStatus; 228 } 229 230 237 public StatusData checkout() { 238 VFSStatus retnStatus = new VFSStatus(); 239 retnStatus.setMethodName(VirtualFile.METHOD_CHECKOUT); 240 241 VirtualFile vfLive = this.m_vfs.getVirtualFile(this.getLiveVersionPath()).getResource(); 242 StatusData vfsStatus = ((AbstractVersioningVFS)this.m_vfs).checkoutVirtualFile(this.getFullPath()); 243 retnStatus.addStatusData(vfsStatus); 244 this.m_vfs.getVirtualFile(vfLive.getFilePath()).getResource().fireVirtualFileEvent(VirtualFileEvent.FILE_MEMBERS_CHANGED); 245 246 return retnStatus; 247 } 248 249 255 public StatusData uncheckout() { 256 return null; 257 } 258 259 265 public StatusData checkin() { 266 VFSStatus retnStatus = new VFSStatus(); 267 retnStatus.setMethodName(VirtualFile.METHOD_CHECKIN); 268 269 VirtualFile vfLogicalFile = null; 270 if(this.getLiveVersionPath()!=null) { 271 vfLogicalFile = this.m_vfs.getVirtualFile(this.getLiveVersionPath()).getResource(); 272 } else { 273 vfLogicalFile = this; 274 } 275 276 StatusData vfsStatus = ((AbstractVersioningVFS)this.m_vfs).checkinVirtualFile(this.getFullPath()); 277 retnStatus.addStatusData(vfsStatus); 278 279 if(retnStatus.isOK()) { 280 this.fireVirtualFileEvent(VirtualFileEvent.FILE_CHECKED_IN); 281 if(vfLogicalFile!=null) { 282 this.setState(VirtualFile.STATE_LIVE); 283 this.m_vfs.getVirtualFile( vfLogicalFile.getFilePath() ).getResource().fireVirtualFileEvent(VirtualFileEvent.FILE_MEMBERS_CHANGED); 284 } else { 285 this.setState(VirtualFile.STATE_LIVE); 286 this.m_vfs.getVirtualFile(this.getFilePath()).getResource().fireVirtualFileEvent(VirtualFileEvent.FILE_MEMBERS_CHANGED); 287 } 288 } 289 290 return retnStatus; 291 } 292 293 298 public StatusData tag(String sTag) { 299 VFSStatus retnStatus = new VFSStatus(); 300 retnStatus.setMethodName(VirtualFile.METHOD_TAG); 301 302 StatusData vfsStatus = ((AbstractVersioningVFS)this.m_vfs).tagVirtualFile(this.getFullPath(), sTag); 303 retnStatus.addStatusData(vfsStatus); 304 305 return retnStatus; 306 } 307 308 313 public StatusData delete() { 314 VFSStatus retnStatus = new VFSStatus(); 315 retnStatus.setMethodName(VirtualFile.METHOD_DELETE); 316 317 VersionedVirtualFile vfLiveFile = null; 318 VirtualFile vfParent = null; 319 if(this.getState().equals(VirtualFile.STATE_PENDING) && this.m_sLiveVersionPath!=null) { 320 vfParent = this.m_vfs.getVirtualFile(this.m_vfs.getVirtualFile(this.m_sLiveVersionPath).getResource().getFilePath()).getResource(); 321 vfLiveFile = (VersionedVirtualFile) this.m_vfs.getVirtualFile(m_sLiveVersionPath).getResource(); 322 } else { 323 vfParent = this.m_vfs.getVirtualFile( this.m_vfs.getParentPath(this.getFullPath())).getResource(); 324 } 325 326 StatusData vfsStatus = this.m_vfs.deleteVirtualFile(this.getFullPath()); 327 retnStatus.addStatusData(vfsStatus); 328 329 if(retnStatus.isOK()) { 330 this.fireVirtualFileEvent(VirtualFileEvent.FILE_DELETED); 331 if(this.getState().equals(VirtualFile.STATE_PENDING) && this.m_sLiveVersionPath!=null) { 332 vfLiveFile.setPendingVersionPath(null); 333 } 334 vfParent.removeChild(this.getFullPath()); 335 vfParent.fireVirtualFileEvent(VirtualFileEvent.FILE_MEMBERS_CHANGED); 336 } 337 338 return retnStatus; 339 } 340 341 } 342
| Popular Tags
|