Master mergerd
This commit is contained in:
commit
1506270dec
0
buisnesslogic/src/main/java/com/plannaplan/entities/Exchange.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/entities/Exchange.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/models/MatchData.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/models/MatchData.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/repositories/ExchangeRepository.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/repositories/ExchangeRepository.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/services/ExchangeService.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/services/ExchangeService.java
Normal file → Executable file
@ -32,7 +32,7 @@ public class UserService {
|
|||||||
/**
|
/**
|
||||||
* checks if user exist and return him or creates new one with student role
|
* checks if user exist and return him or creates new one with student role
|
||||||
* otherwise
|
* otherwise
|
||||||
*
|
*
|
||||||
* @param email user email in usos
|
* @param email user email in usos
|
||||||
* @param usosId user id in usos
|
* @param usosId user id in usos
|
||||||
* @return user entity instace containing changes saved in database
|
* @return user entity instace containing changes saved in database
|
||||||
@ -43,7 +43,7 @@ public class UserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if user exist and creates new one if doesn't
|
* checks if user exist and creates new one if doesn't
|
||||||
*
|
*
|
||||||
* @param email user email in usos
|
* @param email user email in usos
|
||||||
* @param usosId user id in usos
|
* @param usosId user id in usos
|
||||||
* @param roleIfNotExist role to be set in case user is not in database yet
|
* @param roleIfNotExist role to be set in case user is not in database yet
|
||||||
@ -72,7 +72,7 @@ public class UserService {
|
|||||||
/**
|
/**
|
||||||
* generates token for user and if user don't have name in database it will
|
* generates token for user and if user don't have name in database it will
|
||||||
* attemp to obtain these from usos api and saves changes in database
|
* attemp to obtain these from usos api and saves changes in database
|
||||||
*
|
*
|
||||||
* @param authority user we want to login
|
* @param authority user we want to login
|
||||||
* @return user with changed values after save in db
|
* @return user with changed values after save in db
|
||||||
* @throws UserNotFoundException throwed if user doesn't exist
|
* @throws UserNotFoundException throwed if user doesn't exist
|
||||||
@ -94,7 +94,7 @@ public class UserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* sacves user to databse and return instatnce with id
|
* sacves user to databse and return instatnce with id
|
||||||
*
|
*
|
||||||
* @param user to be saved
|
* @param user to be saved
|
||||||
* @return instatnce with bd id
|
* @return instatnce with bd id
|
||||||
*/
|
*/
|
||||||
@ -103,7 +103,7 @@ public class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param email of user to be find
|
* @param email of user to be find
|
||||||
* @return user with given mail
|
* @return user with given mail
|
||||||
* @throws UserNotFoundException throwed if user doesn't exist
|
* @throws UserNotFoundException throwed if user doesn't exist
|
||||||
@ -116,7 +116,7 @@ public class UserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* return user by given authority
|
* return user by given authority
|
||||||
*
|
*
|
||||||
* @param authority user usosId or email
|
* @param authority user usosId or email
|
||||||
* @return optional with user if found
|
* @return optional with user if found
|
||||||
*/
|
*/
|
||||||
@ -130,7 +130,7 @@ public class UserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* search for user with given query
|
* search for user with given query
|
||||||
*
|
*
|
||||||
* @param query string that will be matched to users name and surname
|
* @param query string that will be matched to users name and surname
|
||||||
* @return list opf results
|
* @return list opf results
|
||||||
*/
|
*/
|
||||||
@ -160,7 +160,7 @@ public class UserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* get students sorted by their ranking
|
* get students sorted by their ranking
|
||||||
*
|
*
|
||||||
* @return list of students
|
* @return list of students
|
||||||
*/
|
*/
|
||||||
public List<User> getStudentsSortedByRanking() {
|
public List<User> getStudentsSortedByRanking() {
|
||||||
@ -169,4 +169,4 @@ public class UserService {
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,32 +43,33 @@ public class UsosApiService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* /services/users/user
|
* /services/users/user
|
||||||
*
|
*
|
||||||
* @param usosId user id in usos
|
* @param usosId user id in usos
|
||||||
* @return UserApiResponse modle contatining desired values
|
* @return UserApiResponse modle contatining desired values
|
||||||
*/
|
*/
|
||||||
public UserApiResponse getUserData(String usosId) {
|
public UserApiResponse getUserData(String usosId) {
|
||||||
final UserApiResponse apiResponse = new UserApiResponse();
|
final UserApiResponse apiResponse = new UserApiResponse();
|
||||||
try {
|
try {
|
||||||
final OAuth10aService service = new ServiceBuilder(apikey).apiSecret(apisecret)
|
final OAuth10aService service = new ServiceBuilder(apikey).apiSecret(apisecret)
|
||||||
.build(UsosOauth1Service.instance());
|
.build(UsosOauth1Service.instance());
|
||||||
|
|
||||||
final OAuthRequest request = new OAuthRequest(Verb.GET, apiUrl + "/services/users/user?user_id=" + usosId);
|
final OAuthRequest request = new OAuthRequest(Verb.GET, apiUrl + "/services/users/user?user_id=" + usosId);
|
||||||
service.signRequest(new OAuth1AccessToken("", ""), request);
|
service.signRequest(new OAuth1AccessToken("", ""), request);
|
||||||
|
try (Response response = service.execute(request)) {
|
||||||
|
final String json = response.getBody();
|
||||||
|
if (!json.equals("null")){
|
||||||
|
final ObjectMapper mapper = new ObjectMapper();
|
||||||
|
Map<String, String> map = mapper.readValue(json, new TypeReference<Map<String, String>>() {
|
||||||
|
});
|
||||||
|
apiResponse.setName(map.get(NAME_FIELD));
|
||||||
|
apiResponse.setSurname(map.get(SURNAME_FIELD));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException | InterruptedException | ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
try (Response response = service.execute(request)) {
|
return apiResponse;
|
||||||
final String json = response.getBody();
|
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
|
||||||
Map<String, String> map = mapper.readValue(json, new TypeReference<Map<String, String>>() {
|
|
||||||
});
|
|
||||||
apiResponse.setName(map.get(NAME_FIELD));
|
|
||||||
apiResponse.setSurname(map.get(SURNAME_FIELD));
|
|
||||||
}
|
|
||||||
} catch (IOException | InterruptedException | ExecutionException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return apiResponse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
0
buisnesslogic/src/test/java/com/plannaplan/repositories/ExchangeRepositoryTest.java
Normal file → Executable file
0
buisnesslogic/src/test/java/com/plannaplan/repositories/ExchangeRepositoryTest.java
Normal file → Executable file
0
buisnesslogic/src/test/java/com/plannaplan/services/ExchangeServiceTest.java
Normal file → Executable file
0
buisnesslogic/src/test/java/com/plannaplan/services/ExchangeServiceTest.java
Normal file → Executable file
0
restservice/src/main/java/com/plannaplan/controllers/ExchangeController.java
Normal file → Executable file
0
restservice/src/main/java/com/plannaplan/controllers/ExchangeController.java
Normal file → Executable file
0
restservice/src/main/java/com/plannaplan/responses/mappers/ExchangeResponseMappers.java
Normal file → Executable file
0
restservice/src/main/java/com/plannaplan/responses/mappers/ExchangeResponseMappers.java
Normal file → Executable file
0
restservice/src/main/java/com/plannaplan/responses/models/ExchangeResponse.java
Normal file → Executable file
0
restservice/src/main/java/com/plannaplan/responses/models/ExchangeResponse.java
Normal file → Executable file
0
restservice/src/test/java/com/plannaplan/controllers/ExchangeControllerTest.java
Normal file → Executable file
0
restservice/src/test/java/com/plannaplan/controllers/ExchangeControllerTest.java
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user