You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: repository.go
    path of file: ./repos/harbor/src/server/v2.0/handler
    
    the code of the file until where you have to start completion: // Copyright Project Harbor Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in c
    
func (r *repositoryAPI) ListAllRepositories(ctx context.Context, params operation.ListAllRepositoriesParams) middleware.Responder {
	// set query
	query, err := r.BuildQuery(ctx, params.Q, params.Sort, params.Page, params.PageSize)
	if err != nil {
		return r.SendError(ctx, err)
	}
	secCtx, ok := security.FromContext(ctx)
	if !ok {
		return r.SendError(ctx, errors.UnauthorizedError(errors.New("security context not found")))
	}
	if !secCtx.IsSysAdmin() && !secCtx.IsSolutionUser() {
		projectIDs, err := r.listAuthorizedProjectIDs(ctx)
		if err != nil {
			return r.SendError(ctx, err)
		}
		// no authorized projects, return nil directly
		if len(projectIDs) == 0 {
			return operation.NewListAllRepositoriesOK().
				WithXTotalCount(0).
				WithLink(r.Links(ctx, params.HTTPRequest.URL, 0, query.PageNumber, query.PageSize).String()).
				WithPayload(nil)
		}
		orList := &q.OrList{}
		for _, projectID := range projectIDs {
			orList.Values = append(orList.Values, projectID)
		}
		query.Keywords["ProjectID"] = orList
	}

	total, err := r.repoCtl.Count(ctx, query)
	if err != nil {
		return r.SendError(ctx, err)
	}
	repositories, err := r.repoCtl.List(ctx, query)
	if err != nil {
		return r.SendError(ctx, err)
	}
	var repos []*models.Repository
	for _, repository := range repositories {
		repos = append(repos, r.assembleRepository(ctx, model.NewRepoRecord(repository)))
	}
	return operation.NewListAllRepositoriesOK().
		WithXTotalCount(total).
		WithLink(r.Links(ctx, params.HTTPRequest.URL, total, query.PageNumber, query.PageSize).String()).
		WithPayload(repos)
}