Skip to content

Commit

Permalink
Merge branch 'features/refactor-rights-access'
Browse files Browse the repository at this point in the history
  • Loading branch information
brasseld committed Nov 23, 2015
2 parents fd819bb + 98b0635 commit b77b1bc
Show file tree
Hide file tree
Showing 12 changed files with 332 additions and 344 deletions.
101 changes: 26 additions & 75 deletions src/main/java/io/gravitee/repository/management/api/ApiRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,105 +17,56 @@

import io.gravitee.repository.exceptions.TechnicalException;
import io.gravitee.repository.management.model.Api;
import io.gravitee.repository.management.model.Team;
import io.gravitee.repository.management.model.User;
import io.gravitee.repository.management.model.Visibility;
import io.gravitee.repository.management.model.Membership;
import io.gravitee.repository.management.model.MembershipType;

import java.util.Optional;
import java.util.Collection;
import java.util.Set;

/**
* @author David BRASSELY (brasseld at gmail.com)
*/
public interface ApiRepository {
public interface ApiRepository extends CrudRepository<Api, String>{

/**
* Get an API using its name.
* List all APIs.
*
* @param apiName The name of the API to retrieve.
* @return An {@link Optional} API.
*/
Optional<Api> findByName(String apiName) throws TechnicalException;

/**
* List all public APIs.
*
* @return All public APIs.
* @return All APIs.
*/
Set<Api> findAll() throws TechnicalException;

/**
* List APIs (public and/or private) hold by a {@link Team}.
*
* @param teamName The name of the team.
* @param publicOnly List only public APIs.
* @return List APIs from a team.
*/
Set<Api> findByTeam(String teamName, boolean publicOnly) throws TechnicalException;

/**
* List APIs (public and private) hold by a {@link User}.
* List APIs for a given user and a given membership type.
*
* @param username The name of the user.
* @param publicOnly List only public APIs.
* @param membershipType API membership type filter.
* @return List APIs from a user.
*/
Set<Api> findByUser(String username, boolean publicOnly) throws TechnicalException;

/**
* Create an API
*
* @param api api to create
* @return api creaded
*/
Api create(Api api) throws TechnicalException;

/**
* Update an API
*
* @param api api to update
* @return api updated
*/
Api update(Api api) throws TechnicalException;

/**
* Delete an API
*
* @param apiName api name to delete
*/
void delete(String apiName) throws TechnicalException;
Set<Api> findByMember(String username, MembershipType membershipType, Visibility visibility) throws TechnicalException;

/**
* Count all APIs (public and private) owned by a given {@link User}
*
* @param username owner user name
* @param publicOnly List only public APIs.
* Count all APIs for a given user and a given membership type.
*
* @param username owner user name
* @param membershipType API membership type filter.
* @return counted APIs
*/
int countByUser(String username, boolean publicOnly) throws TechnicalException;

/**
* Count all APIs (public and private) owned by a given {@link Team}
*
* @param teamName owner team name
* @param publicOnly List only public APIs.
* @return counted APIs
*/
int countByTeam(String teamName, boolean publicOnly) throws TechnicalException;

/**
* Find APIs by creator
*
* @param userName creator {@link User} name
* @return APIs created by the user
*/
Set<Api> findByCreator(String userName) throws TechnicalException;

int countByUser(String username, MembershipType membershipType) throws TechnicalException;

/**
* Find Apis associated with an application
*
* Find APIs associated with an application
*
* @param application Application Name
* @return Apis associated
*/
Set<Api> findByApplication(String application) throws TechnicalException;

}
void saveMember(String api, String username, MembershipType membershipType) throws TechnicalException;

void deleteMember(String api, String username) throws TechnicalException;

Collection<Membership> getMembers(String api, MembershipType membershipType) throws TechnicalException;

Membership getMember(String api, String username) throws TechnicalException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
*/
package io.gravitee.repository.management.api;

import java.util.Optional;
import java.util.Set;

import io.gravitee.repository.exceptions.TechnicalException;
import io.gravitee.repository.management.model.Application;
import io.gravitee.repository.management.model.Team;
import io.gravitee.repository.management.model.User;
import io.gravitee.repository.management.model.*;

import java.util.Collection;
import java.util.Set;

/**
* @author David BRASSELY (brasseld at gmail.com)
*/
public interface ApplicationRepository {
public interface ApplicationRepository extends CrudRepository<Application, String> {

/**
* List all applications.
Expand All @@ -35,66 +33,27 @@ public interface ApplicationRepository {
*/
Set<Application> findAll() throws TechnicalException;

/**
* List all applications hold by a {@link Team}.
*
* @param teamName The name of the team.
* @return All applications from a team.
*/
Set<Application> findByTeam(String teamName) throws TechnicalException;

/**
* List all applications hold by a {@link User}.
*
* @param userName The name of the user.
* @param username The name of the user.
* @return All applications from a user.
*/
Set<Application> findByUser(String userName) throws TechnicalException;

/**
* Create an {@link Application}
*
* @param application Application to create
* @return Application created
*/
Application create(Application application) throws TechnicalException;

/**
* Update an {@link Application}
*
* @param application Application to update
* @return Application updated
*/
Application update(Application application) throws TechnicalException;

/**
* Get an application using its name.
*
* @param applicationName The name of the application to retrieve.
* @return An {@link Optional} application.
*/
Optional<Application> findByName(String applicationName) throws TechnicalException;

/**
* Delete an {@link Application}
*
* @param applicationName Application name to delete
*/
void delete(String applicationName) throws TechnicalException;
Set<Application> findByUser(String username, MembershipType membershipType) throws TechnicalException;

/**
* Count {@link Application} owner by a given {@link User}
*
*
* @param userName Application user owner name
* @return Counted application
*/
int countByUser(String userName) throws TechnicalException;
int countByUser(String userName, MembershipType membershipType) throws TechnicalException;

/**
* Count {@link Team} owner by a given {@link User}
*
* @param teamName Application user owner team
* @return Counted application
*/
int countByTeam(String teamName) throws TechnicalException;
}
void saveMember(String application, String username, MembershipType membershipType) throws TechnicalException;

void deleteMember(String application, String username) throws TechnicalException;

Collection<Membership> getMembers(String application, MembershipType membershipType) throws TechnicalException;

Membership getMember(String application, String username) throws TechnicalException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.management.api;

import io.gravitee.repository.exceptions.TechnicalException;

import java.util.Optional;

/**
* @author David BRASSELY (brasseld at gmail.com)
*/
interface CrudRepository<T, ID> {

Optional<T> findById(ID id) throws TechnicalException;

T create(T item) throws TechnicalException;

T update(T item) throws TechnicalException;

void delete(ID id) throws TechnicalException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,19 @@
*/
package io.gravitee.repository.management.api;

import java.util.Collection;
import java.util.Optional;
import java.util.Set;

import io.gravitee.repository.exceptions.TechnicalException;
import io.gravitee.repository.management.model.Page;

import java.util.Collection;

/**
* @author Titouan COMPIEGNE
*/
public interface PageRepository {
public interface PageRepository extends CrudRepository<Page, String> {

Collection<Page> findPublishedByApi(String apiName) throws TechnicalException;

Collection<Page> findByApi(String apiName) throws TechnicalException;

Optional<Page> findByName(String name) throws TechnicalException;

Page create(Page page) throws TechnicalException;

Page update(Page page) throws TechnicalException;

void delete(String name) throws TechnicalException;


Integer findMaxPageOrderByApiName(String apiName) throws TechnicalException;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@
*/
package io.gravitee.repository.management.api;

import java.util.Optional;
import java.util.Set;

import io.gravitee.repository.exceptions.TechnicalException;
import io.gravitee.repository.management.model.User;

import java.util.Optional;
import java.util.Set;

/**
* @author David BRASSELY (brasseld at gmail.com)
*/
public interface UserRepository {

/**
* Create a {@link User}
*
* @param user user to create
* @return User created
*/
/**
* Create a {@link User}
*
* @param user user to create
* @return User created
*/
User create(User user) throws TechnicalException;

/**
* Find a {@link User} by name
*
*
* @param username Name of the searched user
* @return Option user found
*/
Expand All @@ -52,16 +52,8 @@ public interface UserRepository {

/**
* Find all {@link User}s
*
*
* @return Users found
*/
Set<User> findAll() throws TechnicalException;

/**
* Find all {@link User} in a team
*
* @param teamName name of the team
* @return users found
*/
Set<User> findByTeam(String teamName) throws TechnicalException;
}
Set<User> findAll() throws TechnicalException;
}
Loading

0 comments on commit b77b1bc

Please sign in to comment.