Skip to content

Commit fbd3f45

Browse files
committed
upgrade existing documents to comply with the new 0.6 version of the spec, and bump the library version to be in line with the spec
1 parent bfeed3c commit fbd3f45

File tree

9 files changed

+88
-8
lines changed

9 files changed

+88
-8
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.openarchives</groupId>
88
<artifactId>resourcesync</artifactId>
9-
<version>0.5-SNAPSHOT</version>
9+
<version>0.6-SNAPSHOT</version>
1010

1111
<build>
1212
<plugins>

src/main/java/org/openarchives/resourcesync/ChangeList.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@
44

55
public class ChangeList extends UrlSet
66
{
7+
public ChangeList()
8+
{
9+
this(null, null, null);
10+
}
11+
712
public ChangeList(Date lastMod)
813
{
9-
this(lastMod, null);
14+
this(lastMod, null, null);
1015
}
1116

1217
public ChangeList(String capabilityList)
1318
{
14-
this(null, capabilityList);
19+
this(null, capabilityList, null);
1520
}
1621

1722
public ChangeList(Date lastMod, String capabilityList)
23+
{
24+
this(lastMod, capabilityList, null);
25+
}
26+
27+
public ChangeList(Date lastMod, String capabilityList, String changeListArchive)
1828
{
1929
super(ResourceSync.CAPABILITY_CHANGELIST);
2030
this.setLastModified(lastMod);
@@ -25,6 +35,11 @@ public ChangeList(Date lastMod, String capabilityList)
2535
}
2636
}
2737

38+
public void inChangeListArchive(String changeListArchive)
39+
{
40+
this.addLn(ResourceSync.REL_UP, changeListArchive);
41+
}
42+
2843
public void addChange(URL change)
2944
{
3045
this.addUrl(change);

src/main/java/org/openarchives/resourcesync/ChangeListArchive.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public ChangeListArchive(Date lastMod)
1717

1818
public ChangeListArchive(Date lastMod, String capabilityList)
1919
{
20-
super(ResourceSync.CAPABILITY_CHANGELIST);
20+
super(ResourceSync.CAPABILITY_CHANGELIST_ARCHIVE);
2121

2222
if (lastMod != null)
2323
{
@@ -36,7 +36,7 @@ public ChangeListArchive(Date lastMod, String capabilityList)
3636

3737
public ChangeListArchive(InputStream in)
3838
{
39-
super(ResourceSync.CAPABILITY_CHANGELIST, in);
39+
super(ResourceSync.CAPABILITY_CHANGELIST_ARCHIVE, in);
4040
}
4141

4242
public void addChangeList(Sitemap sitemap)

src/main/java/org/openarchives/resourcesync/ResourceSync.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,24 @@ public class ResourceSync
1919
public static String REL_DESCRIBES = "describes";
2020
public static String REL_COLLECTION = "collection";
2121
public static String REL_RESOURCESYNC = "resourcesync";
22+
public static String REL_UP = "up";
23+
public static String REL_ALTERNATE = "alternate";
24+
public static String REL_CANONICAL = "canonical";
25+
public static String REL_DUPLICATE = "duplicate";
26+
public static String REL_PATCH = "http://www.openarchives.org/rs/terms/patch";
27+
public static String REL_MEMENTO = "memento";
28+
public static String REL_TIMEGATE = "timegate";
29+
public static String REL_VIA = "via";
2230

2331
// capabilities
2432
public static String CAPABILITY_RESOURCELIST = "resourcelist";
33+
public static String CAPABILITY_RESOURCELIST_ARCHIVE = "resourcelist-archive";
2534
public static String CAPABILITY_CHANGELIST = "changelist";
35+
public static String CAPABILITY_CHANGELIST_ARCHIVE = "changelist-archive";
2636
public static String CAPABILITY_RESOURCEDUMP = "resourcedump";
37+
public static String CAPABILITY_RESOURCEDUMP_ARCHIVE = "resourcedump-archive";
2738
public static String CAPABILITY_CHANGEDUMP = "changedump";
39+
public static String CAPABILITY_CHANGEDUMP_ARCHIVE = "changedump-archive";
2840
public static String CAPABILITY_RESOURCEDUMP_MANIFEST = "resourcedump-manifest";
2941
public static String CAPABILITY_CHANGEDUMP_MANIFEST = "changedump-manifest";
3042
public static String CAPABILITY_CAPABILITYLIST = "capabilitylist";

src/main/java/org/openarchives/resourcesync/ResourceSyncEntry.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public abstract class ResourceSyncEntry
2424
protected long length = -1;
2525
protected String path = null;
2626
protected String type = null;
27+
protected String encoding = null;
2728

2829
protected List<ResourceSyncLn> lns = new ArrayList<ResourceSyncLn>();
2930

@@ -79,6 +80,16 @@ public void setType(String type)
7980
this.type = type;
8081
}
8182

83+
public String getEncoding()
84+
{
85+
return encoding;
86+
}
87+
88+
public void setEncoding(String encoding)
89+
{
90+
this.encoding = encoding;
91+
}
92+
8293
public void addHash(String type, String hex)
8394
{
8495
this.hashes.put(type, hex);
@@ -225,6 +236,13 @@ public void populateObject(Element element)
225236
{
226237
this.setType(type);
227238
}
239+
240+
// -encoding
241+
String encoding = mdElement.getAttributeValue("encoding"); // FIXME: namespace?
242+
if (encoding != null && !"".equals(encoding))
243+
{
244+
this.setEncoding(encoding);
245+
}
228246
}
229247

230248
// all the rs:ln elements
@@ -284,6 +302,13 @@ public void populateObject(Element element)
284302
{
285303
link.setType(lnType);
286304
}
305+
306+
// encoding
307+
String lnEncoding = ln.getAttributeValue("encoding"); // FIXME: namespace?
308+
if (lnEncoding != null && !"".equals(lnEncoding))
309+
{
310+
link.setEncoding(lnEncoding);
311+
}
287312
}
288313
}
289314
}
@@ -347,6 +372,11 @@ public Element getElement()
347372
md.setAttribute("type", this.type, ResourceSync.NS_ATOM);
348373
trip = true;
349374
}
375+
if (this.encoding != null)
376+
{
377+
md.setAttribute("encoding", this.encoding); // FIXME: namespace? This comes from the HTTP spec
378+
trip = true;
379+
}
350380
if (trip)
351381
{
352382
root.addContent(md);
@@ -398,6 +428,11 @@ public Element getElement()
398428
link.setAttribute("type", ln.getType(), ResourceSync.NS_ATOM);
399429
trip = true;
400430
}
431+
if (ln.getEncoding() != null)
432+
{
433+
link.setAttribute("encoding", ln.getEncoding()); // FIXME: namespace?
434+
trip = true;
435+
}
401436
if (trip)
402437
{
403438
root.addContent(link);

src/main/java/org/openarchives/resourcesync/ResourceSyncLn.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class ResourceSyncLn
1515
protected String rel = null;
1616
protected int pri = -1;
1717
protected String type = null;
18+
protected String encoding = null;
1819

1920
public void addHash(String type, String hex)
2021
{
@@ -100,4 +101,14 @@ public void setType(String type)
100101
{
101102
this.type = type;
102103
}
104+
105+
public String getEncoding()
106+
{
107+
return encoding;
108+
}
109+
110+
public void setEncoding(String encoding)
111+
{
112+
this.encoding = encoding;
113+
}
103114
}

src/test/java/org/openarchives/resourcesync/test/TestBaseClasses.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public void resourceSyncLn()
3737
ln.setPath("/path/to/file");
3838
ln.setPri(45);
3939
ln.setType("application/pdf");
40+
ln.setEncoding("ascii");
4041

4142
assert ln.getHref().equals("http://it.is.a/url");
4243
assert ln.getRel().equals(ResourceSync.REL_DESCRIBES);
@@ -45,6 +46,7 @@ public void resourceSyncLn()
4546
assert ln.getPath().equals("/path/to/file");
4647
assert ln.getPri() == 45;
4748
assert ln.getType().equals("application/pdf");
49+
assert ln.getEncoding().equals("ascii");
4850

4951
Map<String, String> hashes = ln.getHashes();
5052
boolean seenMd5 = false;
@@ -87,6 +89,7 @@ public void resourceSyncEntry()
8789
entry.setLength(987);
8890
entry.setPath("/path/to/file");
8991
entry.setType("application/pdf");
92+
entry.setEncoding("utf-8");
9093

9194
ResourceSyncLn ln1 = entry.addLn(ResourceSync.REL_DESCRIBES, "http://describes");
9295
ResourceSyncLn ln2 = entry.addLn(ResourceSync.REL_COLLECTION, "http://collection");
@@ -107,6 +110,7 @@ public void resourceSyncEntry()
107110
assert entry.getLength() == 987;
108111
assert entry.getPath().equals("/path/to/file");
109112
assert entry.getType().equals("application/pdf");
113+
assert entry.getEncoding().equals("utf-8");
110114

111115
Map<String, String> hashes = entry.getHashes();
112116
boolean seenMd5 = false;
@@ -185,6 +189,9 @@ public void resourceSyncEntry()
185189
String type = md.getAttributeValue("type", ResourceSync.NS_ATOM);
186190
assert type.equals("application/pdf");
187191

192+
String encoding = md.getAttributeValue("encoding");
193+
assert encoding.equals("utf-8");
194+
188195
String hashAttr = md.getAttributeValue("hash", ResourceSync.NS_ATOM);
189196
String[] hashParts = hashAttr.split(" ");
190197
assert hashParts.length == 2;

src/test/java/org/openarchives/resourcesync/test/TestChangeListArchive.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void blankConstructor()
2121
Date now = new Date();
2222
ChangeListArchive cla = new ChangeListArchive();
2323

24-
assert cla.getCapability().equals(ResourceSync.CAPABILITY_CHANGELIST);
24+
assert cla.getCapability().equals(ResourceSync.CAPABILITY_CHANGELIST_ARCHIVE);
2525
assert cla.getLastModified().getTime() >= now.getTime();
2626

2727
List<ResourceSyncLn> lns = cla.getLns();
@@ -34,7 +34,7 @@ public void construction()
3434
Date now = new Date();
3535
ChangeListArchive cla = new ChangeListArchive(now, "http://capabilitylist");
3636

37-
assert cla.getCapability().equals(ResourceSync.CAPABILITY_CHANGELIST);
37+
assert cla.getCapability().equals(ResourceSync.CAPABILITY_CHANGELIST_ARCHIVE);
3838
assert cla.getLastModified().equals(now);
3939

4040
List<ResourceSyncLn> lns = cla.getLns();

src/test/java/org/openarchives/resourcesync/test/TestParsing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void parseDocument()
7575
ResourceSyncDocument nd = new TestResourceSyncDocument(bais);
7676

7777
// now check that the parsed item is the same as the original one
78-
assert nd.getCapability().equals(ResourceSync.CAPABILITY_CHANGELIST);
78+
assert nd.getCapability().equals(ResourceSync.CAPABILITY_CHANGELIST_ARCHIVE);
7979
assert ResourceSync.DATE_FORMAT.format(now).equals(ResourceSync.DATE_FORMAT.format(nd.getLastModified()));
8080

8181
List<ResourceSyncLn> lns = nd.getLns();

0 commit comments

Comments
 (0)