1 13 package org.jahia.services.version; 14 15 import java.util.HashMap ; 16 import java.util.StringTokenizer ; 17 18 import org.jahia.content.ObjectKey; 19 20 public class RevisionEntry implements EntryStateable, Comparable { 21 22 public static final String REVISION_TITLE = "RevisionTitle"; 23 24 private ContentObjectEntryState entryState; 25 private ObjectKey objectKey; 26 27 private HashMap properties = new HashMap (); 29 30 35 public RevisionEntry(ContentObjectEntryState entryState, 36 ObjectKey objectKey){ 37 this.entryState = entryState; 38 this.objectKey = objectKey; 39 } 40 41 public String getLanguageCode(){ 42 return entryState.getLanguageCode(); 43 } 44 45 public int getVersionID(){ 46 return entryState.getVersionID(); 47 } 48 49 public int getWorkflowState(){ 50 return entryState.getWorkflowState(); 51 } 52 53 public ContentObjectEntryState getEntryState(){ 54 return entryState; 55 } 56 57 public ObjectKey getObjectKey(){ 58 return objectKey; 59 } 60 61 public void setProperty(Object name, Object val ){ 62 this.properties.put(name,val); 63 } 64 65 public Object getProperty(Object name){ 66 return this.properties.get(name); 67 } 68 69 77 public String toString(){ 78 StringBuffer buff = new StringBuffer (objectKey.toString()); 79 buff.append("_"); 80 buff.append(entryState.getWorkflowState()); 81 buff.append("_"); 82 buff.append(entryState.getVersionID()); 83 buff.append("_"); 84 buff.append(entryState.getLanguageCode()); 85 return buff.toString(); 86 } 87 88 96 public boolean equals(Object object){ 97 98 RevisionEntry revisionEntry = (RevisionEntry)object; 99 if ( revisionEntry == null ){ 100 return false; 101 } 102 103 if ( !this.entryState.equals(revisionEntry.getEntryState()) ){ 104 return false; 105 } 106 return (getObjectKey().equals(revisionEntry.getObjectKey())); 107 } 108 109 public int hashCode(){ 110 StringBuffer buff = new StringBuffer (); 111 buff.append(getObjectKey()); 112 buff.append("_"); 113 buff.append(this.getVersionID()); 114 buff.append("_"); 115 buff.append(this.getWorkflowState()); 116 return buff.toString().hashCode(); 117 } 118 123 public static RevisionEntry getRevisionEntry(String revisionEntryKey){ 124 125 RevisionEntry revisionEntry = null; 126 try { 127 StringTokenizer strToken = new StringTokenizer (revisionEntryKey, "_"); 128 String objType = ""; 129 String objID = ""; 130 String w = ""; 131 String v = ""; 132 String l = ""; 133 134 if (strToken.countTokens()==5) { 135 objType = strToken.nextToken(); 136 objID = strToken.nextToken(); 137 w = strToken.nextToken(); 138 v = strToken.nextToken(); 139 l = strToken.nextToken(); 140 ContentObjectEntryState entryState = 141 new ContentObjectEntryState(Integer.parseInt(w), 142 Integer.parseInt(v),l); 143 revisionEntry = 144 new RevisionEntry(entryState, 145 ObjectKey.getInstance(objType + "_" + objID)); 146 } 147 } catch ( Throwable t ){ 148 } 150 return revisionEntry; 151 } 152 153 158 public int compareTo(Object o) { 159 return 1; 160 } 161 } 162 | Popular Tags |