Only construct ChangeResources via ChangesCollection.parse

In a notedb world we would like to slurp all information about a
change from the git-based storage as soon as a ChangeResource is
constructed, which will involve extra work in this parse, analogous to
how parse currently validates the change permissions.

Preserve the ability to pass in a particular ChangeControl object,
since various callers have specific requirements like reusing the
control elsewhere, or using a control for a different user.

Change-Id: Ia7c9761ef92bb8f05ae3323210babaa02b0dbe6f
This commit is contained in:
Dave Borowitz
2013-12-16 14:30:28 -08:00
parent 1691f61558
commit fcb204627b
10 changed files with 66 additions and 39 deletions

View File

@@ -83,6 +83,16 @@ public class ChangesCollection implements
return new ChangeResource(control);
}
public ChangeResource parse(Change.Id id)
throws ResourceNotFoundException, OrmException {
return parse(TopLevelResource.INSTANCE,
IdString.fromUrl(Integer.toString(id.get())));
}
public ChangeResource parse(ChangeControl control) throws OrmException {
return new ChangeResource(control);
}
private List<Change> findChanges(String id)
throws OrmException, ResourceNotFoundException {
// Try legacy id