Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,18 @@
<groupId>org.eclipse.virgo.bundlor</groupId>
<artifactId>org.eclipse.virgo.bundlor.maven</artifactId>
<version>${maven-bundlor-plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.eclipse.virgo.bundlor</groupId>
<artifactId>org.eclipse.virgo.bundlor</artifactId>
<version>1.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.eclipse.virgo.bundlor</groupId>
<artifactId>org.eclipse.virgo.bundlor.blint</artifactId>
<version>1.1.2.RELEASE</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>bundlor</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ public interface SearchImagesCmd extends SyncDockerCmd<List<SearchItem>> {

@CheckForNull
String getTerm();
Integer getLimit();

SearchImagesCmd withTerm(@Nonnull String term);
SearchImagesCmd withLimit(@Nonnull Integer limit);

interface Exec extends DockerCmdSyncExec<SearchImagesCmd, List<SearchItem>> {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.github.dockerjava.core.command;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import java.util.List;

import com.github.dockerjava.api.command.SearchImagesCmd;
import com.github.dockerjava.api.model.SearchItem;
import javax.annotation.Nonnull;

/**
* Search images
Expand All @@ -15,8 +17,10 @@
*
*/
public class SearchImagesCmdImpl extends AbstrDockerCmd<SearchImagesCmd, List<SearchItem>> implements SearchImagesCmd {

private static final int MIN_LIMIT = 1;
private static final int MAX_LIMIT = 100;
private String term;
private Integer limit;

public SearchImagesCmdImpl(SearchImagesCmd.Exec exec, String term) {
super(exec);
Expand All @@ -35,4 +39,17 @@ public SearchImagesCmd withTerm(String term) {
return this;
}

@Override
public Integer getLimit() {
return limit;
}

@Override
public SearchImagesCmd withLimit(@Nonnull Integer limit) {
String errorMessage = String.format("Limit %s is outside the range of [%s, %s]", limit, MIN_LIMIT, MAX_LIMIT);
checkArgument(limit <= MAX_LIMIT, errorMessage);
checkArgument(limit >= MIN_LIMIT, errorMessage);
this.limit = limit;
return this;
}
}
23 changes: 16 additions & 7 deletions src/main/java/com/github/dockerjava/jaxrs/SearchImagesCmdExec.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package com.github.dockerjava.jaxrs;

import com.github.dockerjava.api.command.SearchImagesCmd;
import com.github.dockerjava.api.model.SearchItem;
import com.github.dockerjava.core.DockerClientConfig;
import java.util.List;

import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.dockerjava.api.command.SearchImagesCmd;
import com.github.dockerjava.api.model.SearchItem;
import com.github.dockerjava.core.DockerClientConfig;

public class SearchImagesCmdExec extends AbstrSyncDockerCmdExec<SearchImagesCmd, List<SearchItem>> implements
SearchImagesCmd.Exec {

Expand All @@ -24,7 +21,19 @@ public SearchImagesCmdExec(WebTarget baseResource, DockerClientConfig dockerClie

@Override
protected List<SearchItem> execute(SearchImagesCmd command) {
WebTarget webResource = getBaseResource().path("/images/search").queryParam("term", command.getTerm());
WebTarget webResource = null;

Integer limit = command.getLimit();
if (limit == null) {
webResource = getBaseResource()
.path("/images/search")
.queryParam("term", command.getTerm());
} else {
webResource = getBaseResource()
.path("/images/search")
.queryParam("term", command.getTerm())
.queryParam("limit", command.getLimit());
}

LOGGER.trace("GET: {}", webResource);
return webResource.request().accept(MediaType.APPLICATION_JSON).get(new GenericType<List<SearchItem>>() {
Expand Down