@Override public int hashCode() { int hash = 7; hash = 31 * hash + Objects.hashCode(id); hash = 31 * hash + Objects.hashCode(name); hash = 31 * hash + Objects.hashCode(description); hash = 31 * hash + Objects.hashCode(defaultEnv); hash = 31 * hash + getCommands().hashCode(); hash = 31 * hash + getProjects().hashCode(); hash = 31 * hash + getEnvironments().hashCode(); hash = 31 * hash + getAttributes().hashCode(); return hash; }
@DELETE @Path("/{id}/command/{name}") @ApiOperation( value = "Remove the command from the workspace", notes = "This operation can be performed only by the workspace owner") @ApiResponses({ @ApiResponse(code = 204, message = "The command successfully removed"), @ApiResponse(code = 403, message = "The user does not have access delete the command"), @ApiResponse(code = 404, message = "The workspace not found"), @ApiResponse(code = 500, message = "Internal server error occurred") }) public void deleteCommand( @ApiParam("The id of the workspace") @PathParam("id") String id, @ApiParam("The name of the command to remove") @PathParam("name") String commandName) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException { WorkspaceImpl workspace = workspaceManager.getWorkspace(id); if (workspace .getConfig() .getCommands() .removeIf(command -> command.getName().equals(commandName))) { doUpdate(id, workspace); } }
@POST @Path("/{id}/command") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation( value = "Update the workspace by adding a new command to it", notes = "This operation can be performed only by the workspace owner") @ApiResponses({ @ApiResponse(code = 200, message = "The workspace successfully updated"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 403, message = "The user does not have access to update the workspace"), @ApiResponse(code = 404, message = "The workspace not found"), @ApiResponse(code = 409, message = "The command with such name already exists"), @ApiResponse(code = 500, message = "Internal server error occurred") }) public WorkspaceDto addCommand( @ApiParam("The workspace id") @PathParam("id") String id, @ApiParam(value = "The new workspace command", required = true) CommandDto newCommand) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException { requiredNotNull(newCommand, "Command"); WorkspaceImpl workspace = workspaceManager.getWorkspace(id); workspace.getConfig().getCommands().add(new CommandImpl(newCommand)); return asDtoWithLinksAndToken(doUpdate(id, workspace)); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof WorkspaceConfigImpl)) { return false; } final WorkspaceConfigImpl that = (WorkspaceConfigImpl) obj; return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(defaultEnv, that.defaultEnv) && getCommands().equals(that.getCommands()) && getProjects().equals(that.getProjects()) && getEnvironments().equals(that.getEnvironments()) && getAttributes().equals(that.getAttributes()); }
requiredNotNull(update, "Command update"); WorkspaceImpl workspace = workspaceManager.getWorkspace(id); List<CommandImpl> commands = workspace.getConfig().getCommands(); if (!commands.removeIf(cmd -> cmd.getName().equals(cmdName))) { throw new NotFoundException(