no longer doing caching

This commit is contained in:
Kohsuke Kawaguchi
2011-06-28 17:34:23 -07:00
parent 06dd7c83f8
commit 2fdec0d484
4 changed files with 20 additions and 30 deletions

View File

@@ -33,7 +33,7 @@ public class GHOrganization extends GHPerson {
f.getSelectByName("team_id").getOptionByText(team).setSelected(true);
f.submit(f.getButtonByCaption("Create Repository"));
return refreshRepository(name);
return getRepository(name);
// GHRepository r = new Poster(root).withCredential()
// .with("name", name).with("description", description).with("homepage", homepage)

View File

@@ -17,43 +17,22 @@ public abstract class GHPerson {
protected int public_gist_count,public_repo_count,following_count,id;
/**
* Repositories that this user owns.
*/
private transient Map<String,GHRepository> repositories;
/**
* Gets the repositories this user owns.
*/
public synchronized Map<String,GHRepository> getRepositories() throws IOException {
if (repositories==null) {
repositories = Collections.synchronizedMap(new TreeMap<String, GHRepository>());
for (int i=1; ; i++) {
Map<String, GHRepository> map = root.retrieve("/repos/show/" + login + "?page=" + i, JsonRepositories.class).wrap(root);
repositories.putAll(map);
if (map.isEmpty()) break;
}
Map<String,GHRepository> repositories = new TreeMap<String, GHRepository>();
for (int i=1; ; i++) {
Map<String, GHRepository> map = root.retrieve("/repos/show/" + login + "?page=" + i, JsonRepositories.class).wrap(root);
repositories.putAll(map);
if (map.isEmpty()) break;
}
return Collections.unmodifiableMap(repositories);
}
/**
* Fetches the repository of the given name from GitHub, and return it.
*/
protected GHRepository refreshRepository(String name) throws IOException {
if (repositories==null) getRepositories(); // fetch the base first
GHRepository r = fetchRepository(name);
repositories.put(name,r);
return r;
}
protected GHRepository fetchRepository(String name) throws IOException {
return root.retrieve("/repos/show/" + login + '/' + name, JsonRepository.class).wrap(root);
}
public GHRepository getRepository(String name) throws IOException {
return getRepositories().get(name);
return root.retrieve("/repos/show/" + login + '/' + name, JsonRepository.class).wrap(root);
}
/**

View File

@@ -241,7 +241,7 @@ public class GHRepository {
if (org.getLogin().equals(f.getInputByName("organization").getValueAttribute())) {
// found it
f.submit((HtmlButton)f.getElementsByTagName("button").get(0));
return org.refreshRepository(name);
return org.getRepository(name);
}
} catch (ElementNotFoundException e) {
// continue
@@ -264,7 +264,7 @@ public class GHRepository {
f.submit((HtmlButton)f.getElementsByTagName("button").get(0));
// overwrite fields
final GHRepository r = getOwner().fetchRepository(newName);
final GHRepository r = getOwner().getRepository(newName);
for (Field fi : getClass().getDeclaredFields()) {
if (Modifier.isStatic(fi.getModifiers())) continue;
fi.setAccessible(true);