use of io.dockstore.webservice.core.Tool in project dockstore by dockstore.
the class AdvancedIndexingBenchmarkIT method addLabels.
private void addLabels(long id) {
Response registerPutLabelResponse = client.target("http://localhost:" + SUPPORT.getLocalPort() + "/containers/" + id + "/labels").queryParam("labels", randomlyGeneratedQueryLabels()).request().header(HttpHeaders.AUTHORIZATION, "Bearer iamafakedockstoretoken").put(Entity.entity("asdf", MediaType.APPLICATION_JSON_TYPE));
Tool registeredTool = registerPutLabelResponse.readEntity(Tool.class);
assertEquals(id, registeredTool.getId());
}
use of io.dockstore.webservice.core.Tool in project dockstore by dockstore.
the class LanguageHandlerInterface method getURLFromEntry.
/**
* Given a docker entry (quay or dockerhub), return a URL to the given entry
*
* @param dockerEntry has the docker name
* @return URL
*/
// TODO: Potentially add support for other registries and add message that the registry is unsupported
default String getURLFromEntry(String dockerEntry, ToolDAO toolDAO) {
// For now ignore tag, later on it may be more useful
String quayIOPath = "https://quay.io/repository/";
// For type repo/subrepo:tag
String dockerHubPathR = "https://hub.docker.com/r/";
// For type repo:tag
String dockerHubPathUnderscore = "https://hub.docker.com/_/";
// Update to tools once UI is updated to use /tools instead of /containers
String dockstorePath = "https://www.dockstore.org/containers/";
String url;
// Remove tag if exists
Pattern p = Pattern.compile("([^:]+):?(\\S+)?");
Matcher m = p.matcher(dockerEntry);
if (m.matches()) {
dockerEntry = m.group(1);
}
if (dockerEntry.isEmpty()) {
return null;
}
// Regex for determining registry requires a tag; add a fake "0" tag
Optional<Registry> registry = determineImageRegistry(dockerEntry + ":0");
// TODO: How do we check that the URL is valid? If not then the entry is likely a local docker build
if (registry.isPresent() && registry.get().equals(Registry.QUAY_IO)) {
List<Tool> byPath = toolDAO.findAllByPath(dockerEntry, true);
if (byPath == null || byPath.isEmpty()) {
// when we cannot find a published tool on Dockstore, link to quay.io
url = dockerEntry.replaceFirst("quay\\.io/", quayIOPath);
} else {
// when we found a published tool, link to the tool on Dockstore
url = dockstorePath + dockerEntry;
}
} else if (registry.isEmpty() || !registry.get().equals(Registry.DOCKER_HUB)) {
// if the registry is neither Quay nor Docker Hub, return the entry as the url
url = "https://" + dockerEntry;
} else {
// DOCKER_HUB
String[] parts = dockerEntry.split("/");
if (parts.length == 2) {
// if the path looks like pancancer/pcawg-oxog-tools
List<Tool> publishedByPath = toolDAO.findAllByPath("registry.hub.docker.com/" + dockerEntry, true);
if (publishedByPath == null || publishedByPath.isEmpty()) {
// when we cannot find a published tool on Dockstore, link to docker hub
url = dockerHubPathR + dockerEntry;
} else {
// when we found a published tool, link to the tool on Dockstore
url = dockstorePath + "registry.hub.docker.com/" + dockerEntry;
}
} else {
// if the path looks like debian:8 or debian
url = dockerHubPathUnderscore + dockerEntry;
}
}
return url;
}
use of io.dockstore.webservice.core.Tool in project dockstore by dockstore.
the class CollectionResource method deleteEntryFromCollection.
@DELETE
@Timed
@UnitOfWork
@Path("{organizationId}/collections/{collectionId}/entry")
@ApiOperation(value = "Delete an entry from a collection.", authorizations = { @Authorization(value = JWT_SECURITY_DEFINITION_NAME) }, response = Collection.class)
@Operation(operationId = "deleteEntryFromCollection", summary = "Delete an entry to a collection.", description = "Delete an entry to a collection.", security = @SecurityRequirement(name = "bearer"))
public Collection deleteEntryFromCollection(@ApiParam(hidden = true) @Parameter(hidden = true, name = "user") @Auth User user, @ApiParam(value = "Organization ID.", required = true) @Parameter(description = "Organization ID.", name = "organizationId", in = ParameterIn.PATH, required = true) @PathParam("organizationId") Long organizationId, @ApiParam(value = "Collection ID.", required = true) @Parameter(description = "Collection ID.", name = "collectionId", in = ParameterIn.PATH, required = true) @PathParam("collectionId") Long collectionId, @ApiParam(value = "Entry ID", required = true) @Parameter(description = "Entry ID.", name = "entryId", in = ParameterIn.QUERY, required = true) @QueryParam("entryId") Long entryId, @ApiParam(value = "Version ID", required = false) @Parameter(description = "Version ID.", name = "versionId", in = ParameterIn.QUERY, required = false) @QueryParam("versionName") String versionName) {
// Call common code to check if entry and collection exist and return them
ImmutablePair<Entry, Collection> entryAndCollection = commonModifyCollection(organizationId, entryId, collectionId, user);
Long versionId = null;
if (versionName != null) {
Set<Version> workflowVersions = entryAndCollection.getLeft().getWorkflowVersions();
Optional<Version> first = workflowVersions.stream().filter(version -> version.getName().equals(versionName)).findFirst();
if (first.isPresent()) {
versionId = first.get().getId();
} else {
throw new CustomWebApplicationException("Version not found", HttpStatus.SC_NOT_FOUND);
}
}
// Remove the entry from the organization,
// This silently fails if the user somehow manages to give a non-existent entryId and versionId pair
entryAndCollection.getRight().removeEntry(entryAndCollection.getLeft().getId(), versionId);
// Event for deletion
Organization organization = organizationDAO.findById(organizationId);
Event.Builder eventBuild = new Event.Builder().withOrganization(organization).withCollection(entryAndCollection.getRight()).withInitiatorUser(user).withType(Event.EventType.REMOVE_FROM_COLLECTION);
if (entryAndCollection.getLeft() instanceof BioWorkflow) {
eventBuild = eventBuild.withBioWorkflow((BioWorkflow) entryAndCollection.getLeft());
} else if (entryAndCollection.getLeft() instanceof Service) {
eventBuild = eventBuild.withService((Service) entryAndCollection.getLeft());
} else if (entryAndCollection.getLeft() instanceof Tool) {
eventBuild = eventBuild.withTool((Tool) entryAndCollection.getLeft());
}
Event removeFromCollectionEvent = eventBuild.build();
eventDAO.create(removeFromCollectionEvent);
return collectionDAO.findById(collectionId);
}
use of io.dockstore.webservice.core.Tool in project dockstore by dockstore.
the class DockerRepoResource method getStarredUsers.
@GET
@Path("/{containerId}/starredUsers")
@Timed
@UnitOfWork(readOnly = true)
@Operation(operationId = "getStarredUsers", description = "Returns list of users who starred a tool.")
@ApiOperation(value = "Returns list of users who starred a tool.", response = User.class, responseContainer = "List")
public Set<User> getStarredUsers(@ApiParam(value = "Tool to grab starred users for.", required = true) @PathParam("containerId") Long containerId) {
Tool tool = toolDAO.findById(containerId);
checkEntry(tool);
return tool.getStarredUsers();
}
use of io.dockstore.webservice.core.Tool in project dockstore by dockstore.
the class DockerRepoResource method getPublishedContainer.
@GET
@Timed
@UnitOfWork(readOnly = true)
@Path("/published/{containerId}")
@ApiOperation(value = "Get a published tool.", notes = "NO authentication", response = Tool.class)
public Tool getPublishedContainer(@ApiParam(value = "Tool ID", required = true) @PathParam("containerId") Long containerId, @ApiParam(value = "Comma-delimited list of fields to include: validations") @QueryParam("include") String include) {
Tool tool = toolDAO.findPublishedById(containerId);
checkEntry(tool);
if (checkIncludes(include, "validations")) {
tool.getWorkflowVersions().forEach(tag -> Hibernate.initialize(tag.getValidations()));
}
Hibernate.initialize(tool.getAliases());
return filterContainersForHiddenTags(tool);
}
Aggregations