You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2019/09/03 13:43:38 UTC
[airavata-custos] 43/45: group profile service changes should go in
a different commit
This is an automated email from the ASF dual-hosted git repository.
smarru pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
commit 1b588e97e2acf1279ac5dc4882ca9decdcdaa672
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Sep 2 21:24:05 2019 -0400
group profile service changes should go in a different commit
---
.../group-profile-api/pom.xml | 21 --
.../group/profile/service/api/Application.java | 28 --
.../api/controllers/GroupServiceController.java | 82 -----
.../group-profile-core/pom.xml | 45 ---
.../exceptions/GroupManagerServiceException.java | 16 -
.../profile/service/core/models/GroupModel.java | 73 ----
.../service/core/service/GroupProfileService.java | 370 ---------------------
.../group-profile-service/pom.xml | 20 --
custos-profile-service/pom.xml | 1 -
9 files changed, 656 deletions(-)
diff --git a/custos-profile-service/group-profile-service/group-profile-api/pom.xml b/custos-profile-service/group-profile-service/group-profile-api/pom.xml
deleted file mode 100644
index 1c5e69f..0000000
--- a/custos-profile-service/group-profile-service/group-profile-api/pom.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>group-profile-service</artifactId>
- <groupId>org.apache.custos</groupId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>group-profile-api</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.apache.custos</groupId>
- <artifactId>group-profile-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/Application.java b/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/Application.java
deleted file mode 100644
index 75f11de..0000000
--- a/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/Application.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.group.profile.service.api;
-
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.ComponentScan;
-
-@SpringBootApplication
-@ComponentScan(basePackages = {"org.apache.custos.group.profile.api.controllers"})
-public class Application {
-}
diff --git a/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/controllers/GroupServiceController.java b/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/controllers/GroupServiceController.java
deleted file mode 100644
index 04b8dba..0000000
--- a/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/controllers/GroupServiceController.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.apache.group.profile.service.api.controllers;
-
-import org.apache.custos.profile.service.core.models.GroupModel;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-import java.util.Map;
-
-@RestController
-@RequestMapping("/group")
-public class GroupServiceController {
-
- @RequestMapping(method = RequestMethod.POST)
- public ResponseEntity<String> createGroup(@RequestBody GroupModel groupModel){
- return null;
- }
-
- @RequestMapping(method = RequestMethod.PUT)
- public ResponseEntity<String> updateGroup(@RequestBody GroupModel groupModel){
- return null;
- }
-
- @RequestMapping(value = "/id/{groupId}/owner/{ownerId}", method = RequestMethod.DELETE)
- public ResponseEntity<String> deleteGroup(@PathVariable("groupId") String groupId, @PathVariable("ownerId") String ownerId){
- return null;
- }
-
- @RequestMapping(value = "/id/{groupId}", method = RequestMethod.GET)
- public ResponseEntity<String> getGroup(@PathVariable("groupId") String groupId){
- return null;
- }
-
- @RequestMapping(value = "/all", method = RequestMethod.GET)
- public @ResponseBody
- List<GroupModel> getGroups(){
- return null;
- }
-
- @RequestMapping(value = "/username/{username}", method = RequestMethod.GET)
- public @ResponseBody
- List<GroupModel> getAllGroupsUserBelongs(@PathVariable("username") String username){
- return null;
- }
-
- @RequestMapping(value = "/id/{groupId}", method = RequestMethod.PUT)
- public ResponseEntity<String> addUsersToGroup(@PathVariable("groupId") String groupId, @RequestBody List<String> userIds){
- return null;
- }
-
- @RequestMapping(value = "/id/{groupId}", method = RequestMethod.PUT)
- public ResponseEntity<String> removeUsersFromGroup(@PathVariable("groupId") String groupId, @RequestBody List<String> userIds){
- return null;
- }
-
- @RequestMapping(value = "/id/{groupId}/owner/{ownerId}", method = RequestMethod.PUT)
- public ResponseEntity<String> transferGroupOwnership(@PathVariable("groupId") String groupId, @PathVariable("ownerId") String ownerId){
- return null;
- }
-
- @RequestMapping(value = "addAdmins/id/{groupId}", method = RequestMethod.PUT)
- public ResponseEntity<String> addGroupAdmins(@PathVariable("groupId") String groupId, @RequestBody List<String> adminIds){
- return null;
- }
-
- @RequestMapping(value = "removeAdmins/id/{groupId}", method = RequestMethod.PUT)
- public ResponseEntity<String> removeGroupAdmins(@PathVariable("groupId") String groupId, @RequestBody List<String> adminIds){
- return null;
- }
-
- @RequestMapping(value = "/id/{groupId}/admin/{adminId}", method = RequestMethod.GET)
- public @ResponseBody
- Map<String, Boolean> hasAdminAccess(@PathVariable("groupId") String groupId, @PathVariable("adminId") String adminId){
- return null;
- }
-
- @RequestMapping(value = "/id/{groupId}/owner/{ownerId}", method = RequestMethod.GET)
- public @ResponseBody
- Map<String, Boolean> hasOwnerAccess(@PathVariable("groupId") String groupId, @PathVariable("ownerId") String ownerId){
- return null;
- }
-}
diff --git a/custos-profile-service/group-profile-service/group-profile-core/pom.xml b/custos-profile-service/group-profile-service/group-profile-core/pom.xml
deleted file mode 100644
index 7945596..0000000
--- a/custos-profile-service/group-profile-service/group-profile-core/pom.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>group-profile-service</artifactId>
- <groupId>org.apache.custos</groupId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>group-profile-core</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.apache.custos</groupId>
- <artifactId>user-profile-service</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.custos</groupId>
- <artifactId>sharing-service-api</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.custos</groupId>
- <artifactId>profile-service-commons</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20160212</version>
- <scope>compile</scope>
- </dependency>
- <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>2.8.5</version>
- </dependency>
- </dependencies>
-
-
-</project>
\ No newline at end of file
diff --git a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/exceptions/GroupManagerServiceException.java b/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/exceptions/GroupManagerServiceException.java
deleted file mode 100644
index 6de6312..0000000
--- a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/exceptions/GroupManagerServiceException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.apache.custos.profile.service.core.exceptions;
-
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-@ResponseStatus(value= HttpStatus.INTERNAL_SERVER_ERROR, reason = "Request cannot be completed due to server error")
-public class GroupManagerServiceException extends RuntimeException {
-
- public GroupManagerServiceException(String errorMessage) {
- super(errorMessage);
- }
-
- public GroupManagerServiceException(String errorMessage, Throwable err) {
- super(errorMessage, err);
- }
-}
diff --git a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/models/GroupModel.java b/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/models/GroupModel.java
deleted file mode 100644
index c36d520..0000000
--- a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/models/GroupModel.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.apache.custos.profile.service.core.models;
-
-import java.util.List;
-
-public class GroupModel {
- private String id;
- private String name;
- private String ownerId;
- private String description;
- private String gatewayId;
- private List<String> members;
- /**
- * Note: each admin must also be a member of the group.
- */
- private List<String> admins;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getOwnerId() {
- return ownerId;
- }
-
- public void setOwnerId(String ownerId) {
- this.ownerId = ownerId;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List<String> getMembers() {
- return members;
- }
-
- public void setMembers(List<String> members) {
- this.members = members;
- }
-
- public List<String> getAdmins() {
- return admins;
- }
-
- public void setAdmins(List<String> admins) {
- this.admins = admins;
- }
-
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-}
diff --git a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java b/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java
deleted file mode 100644
index b11b4df..0000000
--- a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java
+++ /dev/null
@@ -1,370 +0,0 @@
-package org.apache.custos.profile.service.core.service;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.google.gson.Gson;
-import org.apache.custos.commons.exceptions.ServiceConnectionException;
-import org.apache.custos.commons.utils.ServiceRequestClient;
-import org.apache.custos.profile.commons.repositories.UserProfileRepository;
-import org.apache.custos.sharing.service.api.constants.SharingRegistryEndpoints;
-import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
-import org.apache.custos.sharing.service.core.models.GroupCardinality;
-import org.apache.custos.sharing.service.core.models.GroupType;
-import org.apache.custos.sharing.service.core.models.UserGroup;
-import org.apache.custos.profile.service.core.models.*;
-import org.apache.custos.profile.service.core.exceptions.*;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.json.HTTP;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class GroupProfileService {
-
- private static final Logger logger = LoggerFactory.getLogger(GroupProfileService.class);
-
- @Autowired
- ServiceRequestClient serviceRequestClient;
-
- @Autowired
- SharingRegistryEndpoints sharingRegistryEndpoints;
-
- private static final String GROUP_MANAGER_CPI_VERSION = "1.0";
- private UserProfileRepository userProfileRepository = new UserProfileRepository();
- private String SHARING_SERVICE_BASE_URL = sharingRegistryEndpoints.getBaseUrl();
-
- public String getAPIVersion() {
- return GROUP_MANAGER_CPI_VERSION;
- }
-
- private JSONObject getResponseBody(HttpResponse response) throws Exception {
-
- try {
- if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
- BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
- StringBuffer result = new StringBuffer();
- String line = "";
- while ((line = rd.readLine()) != null) {
- result.append(line);
- }
- JSONObject jsonObject = new JSONObject(result.toString());
- return jsonObject;
- } else {
- throw new Exception();
- }
- } catch (Exception ex) {
- //TODO: sharing service did not return correct response
- throw ex;
- }
- }
-
- private boolean validateHeadHttpRequest(HttpResponse response) throws Exception{
- if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
- return true;
- }else if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
- return false;
- }
- else {
- //TODO: this will be sharing server error
- throw new Exception();
- }
- }
-
- private boolean validatePutHttpRequest(HttpResponse response) throws Exception{
- if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
- return true;
- } else {
- //TODO: this will be sharing server error
- throw new Exception();
- }
- }
-
- public String createGroup(GroupModel groupModel, String gatewayId, String userId) throws GroupManagerServiceException{
- try {
-
- UserGroup sharingUserGroup = new UserGroup();
- sharingUserGroup.setGroupId(groupModel.getId());
- sharingUserGroup.setName(groupModel.getName());
- sharingUserGroup.setDescription(groupModel.getDescription());
- sharingUserGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
- sharingUserGroup.setGroupCardinality(GroupCardinality.MULTI_USER);
- sharingUserGroup.setDomainId(groupModel.getGatewayId());
- sharingUserGroup.setOwnerId(groupModel.getOwnerId());
-
- HttpResponse response = serviceRequestClient.httpPost(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getCreateGroupApi(groupModel.getGatewayId()), sharingUserGroup);
-
- //TODO: should happen in one rest call
- //internalAddUsersToGroup(sharingClient, gatewayId, groupModel.getMembers(), groupId);
- //addGroupAdmins(authzToken,groupId,groupModel.getAdmins());
- JSONObject responseEntity = getResponseBody(response);
- return responseEntity.get("groupId").toString();
- }catch (ServiceConnectionException ex) {
- //TODO: reason could not make connection request to sharing service
- throw ex;
- }
- catch (Exception e) {
- String msg = "Error Creating Group" ;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
- public boolean updateGroup(GroupModel groupModel, String gatewayId, String userId) throws GroupManagerServiceException{
- try {
- boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(gatewayId, groupModel.getId(), userId)));
- boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(gatewayId, groupModel.getId(), userId)));
- if (!ownerAccess || ! adminAccess) {
- throw new GroupManagerServiceException("User does not have permission to update group");
- }
-
- UserGroup sharingUserGroup = new UserGroup();
- sharingUserGroup.setGroupId(groupModel.getId());
- sharingUserGroup.setName(groupModel.getName());
- sharingUserGroup.setDescription(groupModel.getDescription());
- sharingUserGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
- sharingUserGroup.setDomainId(gatewayId);
-
- //adding and removal of users should be handle separately??
- HttpResponse response = serviceRequestClient.httpPut(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getUpdateGroupApi(groupModel.getGatewayId()), null);
- return validatePutHttpRequest(response);
- }
- catch (Exception e) {
- String msg = "Error Updating Group" ;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
- public boolean deleteGroup(String groupId, String groupGatewayId, String domainId, String ownerId) throws GroupManagerServiceException{
- try {
- boolean hasOwnerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, ownerId)));
- if (!hasOwnerAccess) {
- throw new GroupManagerServiceException("User does not have permission to delete group");
- }
-
-
- serviceRequestClient.httpDelete(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getDeleteGroupApi(groupGatewayId,groupId));
- return true;
- }
- catch (Exception e) {
- String msg = "Error Deleting Group. Group ID: " + groupId ;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
- public GroupModel getGroup(String groupId, String groupGatewayId) throws GroupManagerServiceException{
- try {
- JSONObject jsonObject = getResponseBody(serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGetGroupApi(groupGatewayId, groupId)));
- UserGroup userGroup = new Gson().fromJson(jsonObject.toString(),UserGroup.class);
- GroupModel groupModel = convertToGroupModel(userGroup);
- return groupModel;
- }
- catch (Exception e) {
- String msg = "Error Retreiving Group. Group ID: " + groupId ;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
- public List<GroupModel> getGroups(String groupGatewayId) throws GroupManagerServiceException{
- try {
- JSONObject jsonObject = getResponseBody(serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGetGroupsApi(groupGatewayId, 0, -1)));
- //List<UserGroup> userGroups = new Gson().fromJson(jsonObject.toString(),UserGroup.class);
- List<UserGroup> userGroups = new ArrayList<>();
- return convertToGroupModels(userGroups);
- }
- catch (Exception e) {
- String msg = "Error Retrieving Groups. Domain ID: " + groupGatewayId;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
- public List<GroupModel> getAllGroupsUserBelongs(String userId, String groupGatewayId) throws GroupManagerServiceException{
- try {
- List<GroupModel> groupModels = new ArrayList<GroupModel>();
- JSONObject jsonObject= getResponseBody(serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGetGroupsForUserApi(groupGatewayId, userId)));
- List<UserGroup> userGroups = new ArrayList<>();
- return convertToGroupModels(userGroups);
- }
- catch (Exception e) {
- String msg = "Error Retreiving All Groups for User. User ID: " + userId ;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
- public boolean addUsersToGroup(List<String> userIds, String groupId, String groupGatewayId, String userId, String domainId) throws GroupManagerServiceException{
- try {
- boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
- boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(domainId, groupId, userId)));
- if (! ownerAccess || !adminAccess) {
- throw new GroupManagerServiceException("User does not have access to add users to the group");
- }
- return internalAddUsersToGroup(domainId, userIds, groupId);
-
- } catch (Exception e) {
- String msg = "Error adding users to group. Group ID: " + groupId ;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
- public boolean removeUsersFromGroup(List<String> userIds, String groupId, String groupGatewayId, String userId, String domainId) throws GroupManagerServiceException {
- try {
- boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
- boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(domainId, groupId, userId)));
- if (! ownerAccess || !adminAccess) {
- throw new GroupManagerServiceException("User does not have access to remove users to the group");
- }
- return validateHeadHttpRequest(serviceRequestClient.httpDelete(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getRemoveUsersFromGroupApi(groupGatewayId, groupId)));
- } catch (Exception e) {
- String msg = "Error remove users to group. Group ID: " + groupId ;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
- public boolean transferGroupOwnership(String groupId, String groupGatewayId, String newOwnerId, String userId, String domainId) throws GroupManagerServiceException {
- try{
- boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
- if (!ownerAccess) {
- throw new GroupManagerServiceException("User does not have Owner permission to transfer group ownership");
- }
- return validatePutHttpRequest(serviceRequestClient.httpPut(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getTransferGroupOwnershipApi(groupGatewayId, groupId, newOwnerId), null));
- }
- catch (Exception e) {
- String msg = "Error Transferring Group Ownership";
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
-
- }
-
- public boolean addGroupAdmins(String groupId,String groupGatewayId, List<String> adminIds, String userId, String domainId) throws GroupManagerServiceException {
- try {
- boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
- if (!ownerAccess) {
- throw new GroupManagerServiceException("User does not have Owner permission to add group admins");
- }
- return validatePutHttpRequest(serviceRequestClient.httpPost(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getAddGroupAdminsApi(groupGatewayId, groupId), adminIds));
- }
- catch (Exception e) {
- String msg = "Error Adding Admins to Group. Group ID: " + groupId;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
- public boolean removeGroupAdmins(String groupId, String groupGatewayId,List<String> adminIds, String userId, String domainId) throws GroupManagerServiceException{
- try {
- boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
- if (!ownerAccess) {
- throw new GroupManagerServiceException("User does not have Owner permission to remove group admins");
- }
- return validatePutHttpRequest(serviceRequestClient.httpDelete(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getRemoveGroupAdminsApi(groupGatewayId, groupId)));
- }
- catch (Exception e) {
- String msg = "Error Removing Admins from the Group. Group ID: " + groupId;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
- public boolean hasAdminAccess(String groupId, String adminId, String groupGatewayId) throws GroupManagerServiceException{
- try {
- boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(groupGatewayId, groupId, adminId)));
- return adminAccess;
- }
- catch (Exception e) {
- String msg = "Error Checking Admin Access for the Group. Group ID: " + groupId + " Admin ID: " + adminId;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
- public boolean hasOwnerAccess(String groupId, String groupGatewayId, String ownerId) throws GroupManagerServiceException{
- try {
- boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(groupGatewayId, groupId, ownerId)));
- return ownerAccess;
- }
- catch (Exception e) {
- String msg = "Error Checking Owner Access for the Group. Group ID: " + groupId + " Owner ID: " + ownerId;
- logger.error(msg, e);
- GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
- throw exception;
- }
- }
-
-
- private List<GroupModel> convertToGroupModels(List<UserGroup> userGroups){
-
- List<GroupModel> groupModels = new ArrayList<>();
-
- for (UserGroup userGroup: userGroups) {
- GroupModel groupModel = convertToGroupModel(userGroup);
-
- groupModels.add(groupModel);
- }
- return groupModels;
- }
-
- private GroupModel convertToGroupModel(UserGroup userGroup) {
- GroupModel groupModel = new GroupModel();
- groupModel.setId(userGroup.getGroupId());
- groupModel.setName(userGroup.getName());
- groupModel.setDescription(userGroup.getDescription());
- groupModel.setOwnerId(userGroup.getOwnerId());
- final List<String> admins = userGroup.getGroupAdmins().stream()
- .map(groupAdmin -> groupAdmin.getAdminId())
- .collect(Collectors.toList());
- groupModel.setAdmins(admins);
-
-// serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGroupMemebersOfTypeUserApi(userGroup.getDomainId(), userGroup.getGroupId(), 0, -1)).stream().forEach(user->
-// groupModel.getMembers().add((user.getUserId())
-// );
- return groupModel;
- }
-
- private boolean internalAddUsersToGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException {
-
- // FIXME: workaround for UserProfiles that failed to sync to the sharing
- // registry: create any missing users in the sharing registry
-// for (String userId : userIds) {
-// if (!sharingClient.isUserExists(domainId, userId)) {
-// User user = new User();
-// user.setDomainId(domainId);
-// user.setUserId(userId);
-// UserProfile userProfile = userProfileRepository.get(userId);
-// user.setUserName(userProfile.getUserId());
-// user.setCreatedTime(userProfile.getCreationTime());
-// user.setEmail(userProfile.getEmailsSize() > 0 ? userProfile.getEmails().get(0) : null);
-// user.setFirstName(userProfile.getFirstName());
-// user.setLastName(userProfile.getLastName());
-// sharingClient.createUser(user);
-// }
-// }
-// return serviceRequestClient.httpPost(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getAddUsersToGroupApi(domainId, groupId), userIds);
- return true;
- }
-}
diff --git a/custos-profile-service/group-profile-service/pom.xml b/custos-profile-service/group-profile-service/pom.xml
deleted file mode 100644
index 7d58503..0000000
--- a/custos-profile-service/group-profile-service/pom.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>custos-profile-service</artifactId>
- <groupId>org.apache.custos</groupId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>group-profile-service</artifactId>
- <packaging>pom</packaging>
- <modules>
- <module>group-profile-api</module>
- <module>group-profile-core</module>
- </modules>
-
-
-</project>
\ No newline at end of file
diff --git a/custos-profile-service/pom.xml b/custos-profile-service/pom.xml
index c1802cb..e0ca29a 100644
--- a/custos-profile-service/pom.xml
+++ b/custos-profile-service/pom.xml
@@ -18,7 +18,6 @@
<module>profile-service-model</module>
<module>profile-service-server</module>
<module>tenant-profile-service</module>
- <module>group-profile-service</module>
</modules>
<properties>
<java.version>1.8</java.version>