Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9337344
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
View Options
diff --git a/api/server/src/main/java/org/softwareheritage/graph/SwhId.java b/api/server/src/main/java/org/softwareheritage/graph/SwhId.java
index b413291..49dab71 100644
--- a/api/server/src/main/java/org/softwareheritage/graph/SwhId.java
+++ b/api/server/src/main/java/org/softwareheritage/graph/SwhId.java
@@ -1,59 +1,59 @@
package org.softwareheritage.graph;
import com.fasterxml.jackson.annotation.JsonValue;
public class SwhId {
public static final int HASH_LENGTH = 40;
String swhId;
String type;
String hash;
// SWH ID format: 'swh:1:type:hash'
// https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html
public SwhId(String swhId) {
this.swhId = swhId;
String[] parts = swhId.split(":");
if (parts.length != 4 || !parts[0].equals("swh") || !parts[1].equals("1")) {
throw new IllegalArgumentException("Expected SWH ID format to be 'swh:1:type:hash', got: " + swhId);
}
this.type = parts[2];
if (!type.matches("cnt|dir|rel|rev|snp")) {
throw new IllegalArgumentException("Unknown SWH ID type in: " + swhId);
}
this.hash = parts[3];
if (!hash.matches("[0-9a-f]{" + HASH_LENGTH + "}")) {
- throw new IllegalArgumentException("Unknown SWH ID hash in: " + swhId);
+ throw new IllegalArgumentException("Wrong SWH ID hash format in: " + swhId);
}
}
@Override
public boolean equals(Object otherObj) {
if (otherObj == this) return true;
if (!(otherObj instanceof SwhId)) return false;
SwhId other = (SwhId) otherObj;
return swhId.equals(other.getSwhId());
}
@Override
public String toString() {
return swhId;
}
@JsonValue
public String getSwhId() {
return swhId;
}
public String getType() {
return type;
}
public String getHash() {
return hash;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Jul 4 2025, 8:01 AM (10 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3274486
Attached To
rDGRPH Compressed graph representation
Event Timeline
Log In to Comment