public List<ConcatData> make(List<ConcatUri> resourceUris, boolean isAdjacent) { List<ConcatData> concatUris = Lists.newArrayListWithCapacity(resourceUris.size()); if (resourceUris.isEmpty()) { return concatUris; } ConcatUri exemplar = resourceUris.get(0); String container = exemplar.getContainer(); List<String> versions = null; List<List<Uri>> batches = Lists.newArrayListWithCapacity(resourceUris.size()); for (ConcatUri ctx : resourceUris) { batches.add(ctx.getBatch()); } if (versioner != null) { versions = versioner.version(batches, container); } Iterator<String> versionIt = versions != null ? versions.iterator() : null; for (ConcatUri ctx : resourceUris) { String version = versionIt != null ? versionIt.next() : null; concatUris.add( makeConcatUri(ctx, isAdjacent, version)); } return concatUris; }
public List<ConcatData> make(List<ConcatUri> resourceUris, boolean isAdjacent) { List<ConcatData> concatUris = Lists.newArrayListWithCapacity(resourceUris.size()); if (resourceUris.isEmpty()) { return concatUris; } ConcatUri exemplar = resourceUris.get(0); String container = exemplar.getContainer(); List<String> versions = null; List<List<Uri>> batches = Lists.newArrayListWithCapacity(resourceUris.size()); for (ConcatUri ctx : resourceUris) { batches.add(ctx.getBatch()); } if (versioner != null) { versions = versioner.version(batches, container); } Iterator<String> versionIt = versions != null ? versions.iterator() : null; for (ConcatUri ctx : resourceUris) { String version = versionIt != null ? versionIt.next() : null; concatUris.add( makeConcatUri(ctx, isAdjacent, version)); } return concatUris; }
String concatPath = getReqVal(ctx.getContainer(), CONCAT_PATH_PARAM); List<Uri> resourceUris = ctx.getBatch(); Map<Uri, String> snippets = Maps.newHashMapWithExpectedSize(resourceUris.size());
for (Uri resourceUri : concatUri.getBatch()) { try { HttpRequest httpReq = concatUri.makeHttpRequest(resourceUri);
for (Uri resourceUri : concatUri.getBatch()) { try { HttpRequest httpReq = concatUri.makeHttpRequest(resourceUri);
for (Uri resourceUri : concatUri.getBatch()) { try { requests.add(concatUri.makeHttpRequest(resourceUri));
List<Uri> resourceUris = ctx.getBatch(); Map<Uri, String> snippets = Maps.newHashMapWithExpectedSize(resourceUris.size());
List<Uri> resourceUris = ctx.getBatch(); Map<Uri, String> snippets = Maps.newHashMapWithExpectedSize(resourceUris.size());
private void checkValidatedBatchAdjacent(ConcatUriManager.Type type) throws Exception { // This is essentially the "integration" test ensuring that a // DefaultConcatUriManager's created Uris can be validated by it in turn. Gadget gadget = mockGadget(true, true); String host = "bar.com"; String path = "/other/path"; String[] versions = new String[] { "version1", "v2", "v3" }; ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED, versions); DefaultConcatUriManager manager = makeManager(host, path, "token", versioner); List<List<Uri>> resourceUris = ImmutableList.<List<Uri>>of(RESOURCES_ONE, RESOURCES_TWO, RESOURCES_ONE); List<ConcatData> concatUris = manager.make(fromList(gadget, resourceUris, type), true); assertEquals(3, concatUris.size()); for (int i = 0; i < 3; ++i) { ConcatUriManager.ConcatUri validated = manager.process(concatUris.get(i).getUri()); assertEquals(UriStatus.VALID_VERSIONED, validated.getStatus()); List<Uri> resList = (i % 2 == 0) ? RESOURCES_ONE : RESOURCES_TWO; assertEquals(resList, validated.getBatch()); assertEquals(type, validated.getType()); } }
private void checkValidatedBatchAdjacent(ConcatUriManager.Type type) throws Exception { // This is essentially the "integration" test ensuring that a // DefaultConcatUriManager's created Uris can be validated by it in turn. Gadget gadget = mockGadget(true, true); String host = "bar.com"; String path = "/other/path"; String[] versions = new String[] { "version1"}; ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED, versions); DefaultConcatUriManager manager = makeManager(host, path, "token", versioner); List<List<Uri>> resourceUris = ImmutableList.of(RESOURCES_ONE, RESOURCES_TWO, RESOURCES_ONE); List<ConcatData> concatUris = manager.make(fromList(gadget, resourceUris, type), true); assertEquals(3, concatUris.size()); for (int i = 0; i < 3; ++i) { ConcatUriManager.ConcatUri validated = manager.process(concatUris.get(i).getUris().get(0)); assertEquals(UriStatus.VALID_VERSIONED, validated.getStatus()); List<Uri> resList = (i % 2 == 0) ? RESOURCES_ONE : RESOURCES_TWO; assertEquals(resList, validated.getBatch()); assertEquals(type, validated.getType()); } }
private void checkUnversionedUri(ConcatUriManager.Type type, boolean hasSplit) { // Returns VALID_VERSIONED, but no version is present. ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(UriStatus.VALID_UNVERSIONED, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
private void checkValidatedBatchAdjacent(ConcatUriManager.Type type) throws Exception { // This is essentially the "integration" test ensuring that a // DefaultConcatUriManager's created Uris can be validated by it in turn. Gadget gadget = mockGadget(true, true); String host = "bar.com"; String path = "/other/path"; String[] versions = new String[] { "version1"}; ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED, versions); DefaultConcatUriManager manager = makeManager(host, path, "token", versioner); List<List<Uri>> resourceUris = ImmutableList.of(RESOURCES_ONE, RESOURCES_TWO, RESOURCES_ONE); List<ConcatData> concatUris = manager.make(fromList(gadget, resourceUris, type), true); assertEquals(3, concatUris.size()); for (int i = 0; i < 3; ++i) { ConcatUriManager.ConcatUri validated = manager.process(concatUris.get(i).getUris().get(0)); assertEquals(UriStatus.VALID_VERSIONED, validated.getStatus()); List<Uri> resList = (i % 2 == 0) ? RESOURCES_ONE : RESOURCES_TWO; assertEquals(resList, validated.getBatch()); assertEquals(type, validated.getType()); } }
private void checkUnversionedUri(ConcatUriManager.Type type, boolean hasSplit) { // Returns VALID_VERSIONED, but no version is present. ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(UriStatus.VALID_UNVERSIONED, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
private void checkUnversionedUri(ConcatUriManager.Type type, boolean hasSplit) { // Returns VALID_VERSIONED, but no version is present. ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(UriStatus.VALID_UNVERSIONED, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
private void checkValidateUri(UriStatus status, ConcatUriManager.Type type, boolean hasSplit) { ConcatUriManager.Versioner versioner = makeVersioner(status); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.VERSION.getKey() + "=something&" + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(status, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
public List<ConcatData> make(List<ConcatUri> batches, boolean isAdjacent) { List<ConcatData> results = Lists.newArrayListWithCapacity(batches.size()); for (ConcatUri batch : batches) { UriBuilder uriBuilder = new UriBuilder(base); Integer i = 1; for (Uri uri : batch.getBatch()) { uriBuilder.addQueryParameter((i++).toString(), uri.toString()); } Map<Uri, String> snippets = Maps.newHashMap(); if (!isAdjacent) { for (Uri uri : batch.getBatch()) { snippets.put(uri, uri.toString()); } uriBuilder.addQueryParameter("SPLIT", "1"); } results.add(new ConcatData(Lists.newArrayList(uriBuilder.toUri()), snippets)); } return results; }
private void checkValidateUri(UriStatus status, ConcatUriManager.Type type, boolean hasSplit) { ConcatUriManager.Versioner versioner = makeVersioner(status); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.VERSION.getKey() + "=something&" + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(status, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
private void checkValidateUri(UriStatus status, ConcatUriManager.Type type, boolean hasSplit) { ConcatUriManager.Versioner versioner = makeVersioner(status); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.VERSION.getKey() + "=something&" + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(status, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
public List<ConcatData> make(List<ConcatUri> batches, boolean isAdjacent) { List<ConcatData> results = Lists.newArrayListWithCapacity(batches.size()); for (ConcatUri batch : batches) { UriBuilder uriBuilder = new UriBuilder(base); Integer i = 1; for (Uri uri : batch.getBatch()) { uriBuilder.addQueryParameter((i++).toString(), uri.toString()); } Map<Uri, String> snippets = Maps.newHashMap(); if (!isAdjacent) { for (Uri uri : batch.getBatch()) { snippets.put(uri, uri.toString()); } uriBuilder.addQueryParameter("SPLIT", "1"); } results.add(new ConcatData(uriBuilder.toUri(), snippets)); } return results; }
public List<ConcatData> make(List<ConcatUri> batches, boolean isAdjacent) { List<ConcatData> results = Lists.newArrayListWithCapacity(batches.size()); for (ConcatUri batch : batches) { UriBuilder uriBuilder = new UriBuilder(base); Integer i = 1; for (Uri uri : batch.getBatch()) { uriBuilder.addQueryParameter((i++).toString(), uri.toString()); } Map<Uri, String> snippets = Maps.newHashMap(); if (!isAdjacent) { for (Uri uri : batch.getBatch()) { snippets.put(uri, uri.toString()); } uriBuilder.addQueryParameter("SPLIT", "1"); } results.add(new ConcatData(Lists.newArrayList(uriBuilder.toUri()), snippets)); } return results; }