1 17 package org.alfresco.service.cmr.repository; 18 19 import java.io.Serializable ; 20 21 import org.alfresco.error.AlfrescoRuntimeException; 22 23 28 public final class NodeRef implements EntityRef, Serializable 29 { 30 31 private static final long serialVersionUID = 3760844584074227768L; 32 private static final String URI_FILLER = "/"; 33 34 private final StoreRef storeRef; 35 private final String id; 36 37 43 public NodeRef(StoreRef storeRef, String id) 44 { 45 if (storeRef == null) 46 { 47 throw new IllegalArgumentException ( 48 "Store reference may not be null"); 49 } 50 if (id == null) 51 { 52 throw new IllegalArgumentException ("Node id may not be null"); 53 } 54 55 this.storeRef = storeRef; 56 this.id = id; 57 } 58 59 68 public NodeRef(String nodeRef) 69 { 70 int lastForwardSlash = nodeRef.lastIndexOf('/'); 71 if(lastForwardSlash == -1) 72 { 73 throw new AlfrescoRuntimeException("Invalid node ref - does not contain forward slash: " + nodeRef); 74 } 75 this.storeRef = new StoreRef(nodeRef.substring(0, lastForwardSlash)); 76 this.id = nodeRef.substring(lastForwardSlash+1); 77 } 78 79 public String toString() 80 { 81 return storeRef.toString() + URI_FILLER + id; 82 } 83 84 89 public boolean equals(Object obj) 90 { 91 if (this == obj) 92 { 93 return true; 94 } 95 if (obj instanceof NodeRef) 96 { 97 NodeRef that = (NodeRef) obj; 98 return (this.id.equals(that.id) 99 && this.storeRef.equals(that.storeRef)); 100 } 101 else 102 { 103 return false; 104 } 105 } 106 107 110 public int hashCode() 111 { 112 return id.hashCode(); 113 } 114 115 118 public final StoreRef getStoreRef() 119 { 120 return storeRef; 121 } 122 123 126 public final String getId() 127 { 128 return id; 129 } 130 131 136 public static class Status 137 { 138 private final String changeTxnId; 139 private final boolean deleted; 140 141 public Status(String changeTxnId, boolean deleted) 142 { 143 this.changeTxnId = changeTxnId; 144 this.deleted = deleted; 145 } 146 149 public String getChangeTxnId() 150 { 151 return changeTxnId; 152 } 153 156 public boolean isDeleted() 157 { 158 return deleted; 159 } 160 } 161 } | Popular Tags |