Merge pull request #1186 from dralves/gce-base

gce - paging system bug correction
This commit is contained in:
Adrian Cole 2013-01-16 15:04:21 -08:00
commit b239a0239a
8 changed files with 16 additions and 25 deletions

View File

@ -19,9 +19,9 @@
package org.jclouds.googlecompute.functions.internal; package org.jclouds.googlecompute.functions.internal;
import static com.google.common.base.Predicates.instanceOf; import com.google.common.annotations.Beta;
import static com.google.common.collect.Iterables.tryFind; import com.google.common.base.Function;
import com.google.common.base.Optional;
import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.IterableWithMarker;
import org.jclouds.collect.PagedIterable; import org.jclouds.collect.PagedIterable;
import org.jclouds.collect.PagedIterables; import org.jclouds.collect.PagedIterables;
@ -31,9 +31,8 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.rest.InvocationContext; import org.jclouds.rest.InvocationContext;
import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.GeneratedHttpRequest;
import com.google.common.annotations.Beta; import static com.google.common.base.Predicates.instanceOf;
import com.google.common.base.Function; import static com.google.common.collect.Iterables.tryFind;
import com.google.common.base.Optional;
/** /**
* @author Adrian Cole * @author Adrian Cole
@ -57,13 +56,11 @@ public abstract class BaseToPagedIterable<T, I extends BaseToPagedIterable<T, I>
+ "project", request.getCaller().get().getInvokable()); + "project", request.getCaller().get().getInvokable());
return PagedIterables.advance( return PagedIterables.advance(
input, input, fetchNextPage(project.get().toString(), (ListOptions) listOptions.orNull()));
fetchNextPage(project.get().toString(), (String) input.nextMarker().orNull(),
(ListOptions) listOptions.orNull()));
} }
protected abstract Function<Object, IterableWithMarker<T>> fetchNextPage(String projectName, String marker, protected abstract Function<Object, IterableWithMarker<T>> fetchNextPage(String projectName,
ListOptions listOptions); ListOptions listOptions);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override

View File

@ -56,13 +56,12 @@ public class ParseDisks extends ParseJson<ListPage<Disk>> {
@Override @Override
protected Function<Object, IterableWithMarker<Disk>> fetchNextPage(final String projectName, protected Function<Object, IterableWithMarker<Disk>> fetchNextPage(final String projectName,
final String marker,
final ListOptions options) { final ListOptions options) {
return new Function<Object, IterableWithMarker<Disk>>() { return new Function<Object, IterableWithMarker<Disk>>() {
@Override @Override
public IterableWithMarker<Disk> apply(Object input) { public IterableWithMarker<Disk> apply(Object input) {
return api.getDiskApiForProject(projectName).listAtMarker(marker, options); return api.getDiskApiForProject(projectName).listAtMarker(input.toString(), options);
} }
}; };
} }

View File

@ -54,13 +54,12 @@ public class ParseFirewalls extends ParseJson<ListPage<Firewall>> {
@Override @Override
protected Function<Object, IterableWithMarker<Firewall>> fetchNextPage(final String projectName, protected Function<Object, IterableWithMarker<Firewall>> fetchNextPage(final String projectName,
final String marker,
final ListOptions options) { final ListOptions options) {
return new Function<Object, IterableWithMarker<Firewall>>() { return new Function<Object, IterableWithMarker<Firewall>>() {
@Override @Override
public IterableWithMarker<Firewall> apply(Object input) { public IterableWithMarker<Firewall> apply(Object input) {
return api.getFirewallApiForProject(projectName).listAtMarker(marker, options); return api.getFirewallApiForProject(projectName).listAtMarker(input.toString(), options);
} }
}; };
} }

View File

@ -54,13 +54,12 @@ public class ParseKernels extends ParseJson<ListPage<Kernel>> {
@Override @Override
protected Function<Object, IterableWithMarker<Kernel>> fetchNextPage(final String projectName, protected Function<Object, IterableWithMarker<Kernel>> fetchNextPage(final String projectName,
final String marker,
final ListOptions options) { final ListOptions options) {
return new Function<Object, IterableWithMarker<Kernel>>() { return new Function<Object, IterableWithMarker<Kernel>>() {
@Override @Override
public IterableWithMarker<Kernel> apply(Object input) { public IterableWithMarker<Kernel> apply(Object input) {
return api.getKernelApiForProject(projectName).listAtMarker(marker, options); return api.getKernelApiForProject(projectName).listAtMarker(input.toString(), options);
} }
}; };
} }

View File

@ -54,13 +54,12 @@ public class ParseMachineTypes extends ParseJson<ListPage<MachineType>> {
@Override @Override
protected Function<Object, IterableWithMarker<MachineType>> fetchNextPage(final String projectName, protected Function<Object, IterableWithMarker<MachineType>> fetchNextPage(final String projectName,
final String marker,
final ListOptions options) { final ListOptions options) {
return new Function<Object, IterableWithMarker<MachineType>>() { return new Function<Object, IterableWithMarker<MachineType>>() {
@Override @Override
public IterableWithMarker<MachineType> apply(Object input) { public IterableWithMarker<MachineType> apply(Object input) {
return api.getMachineTypeApiForProject(projectName).listAtMarker(marker, options); return api.getMachineTypeApiForProject(projectName).listAtMarker(input.toString(), options);
} }
}; };
} }

View File

@ -54,13 +54,12 @@ public class ParseNetworks extends ParseJson<ListPage<Network>> {
@Override @Override
protected Function<Object, IterableWithMarker<Network>> fetchNextPage(final String projectName, protected Function<Object, IterableWithMarker<Network>> fetchNextPage(final String projectName,
final String marker,
final ListOptions options) { final ListOptions options) {
return new Function<Object, IterableWithMarker<Network>>() { return new Function<Object, IterableWithMarker<Network>>() {
@Override @Override
public IterableWithMarker<Network> apply(Object input) { public IterableWithMarker<Network> apply(Object input) {
return api.getNetworkApiForProject(projectName).listAtMarker(marker, options); return api.getNetworkApiForProject(projectName).listAtMarker(input.toString(), options);
} }
}; };
} }

View File

@ -54,13 +54,12 @@ public class ParseOperations extends ParseJson<ListPage<Operation>> {
@Override @Override
protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName, protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName,
final String marker,
final ListOptions options) { final ListOptions options) {
return new Function<Object, IterableWithMarker<Operation>>() { return new Function<Object, IterableWithMarker<Operation>>() {
@Override @Override
public IterableWithMarker<Operation> apply(Object input) { public IterableWithMarker<Operation> apply(Object input) {
return api.getOperationApiForProject(projectName).listAtMarker(marker, options); return api.getOperationApiForProject(projectName).listAtMarker(input.toString(), options);
} }
}; };
} }

View File

@ -53,13 +53,13 @@ public class ParseZones extends ParseJson<ListPage<Zone>> {
} }
@Override @Override
protected Function<Object, IterableWithMarker<Zone>> fetchNextPage(final String projectName, final String marker, protected Function<Object, IterableWithMarker<Zone>> fetchNextPage(final String projectName,
final ListOptions options) { final ListOptions options) {
return new Function<Object, IterableWithMarker<Zone>>() { return new Function<Object, IterableWithMarker<Zone>>() {
@Override @Override
public IterableWithMarker<Zone> apply(Object input) { public IterableWithMarker<Zone> apply(Object input) {
return api.getZoneApiForProject(projectName).listAtMarker(marker, options); return api.getZoneApiForProject(projectName).listAtMarker(input.toString(), options);
} }
}; };
} }