|
|
@ -49,10 +49,12 @@ import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.netbeans.lib.cvsclient.commandLine.command.status;
|
|
|
|
|
|
|
|
import org.wso2.carbon.CarbonConstants;
|
|
|
|
import org.wso2.carbon.CarbonConstants;
|
|
|
|
import org.wso2.carbon.context.CarbonContext;
|
|
|
|
import org.wso2.carbon.context.CarbonContext;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.PaginationResult;
|
|
|
|
|
|
|
|
import org.wso2.carbon.user.api.AuthorizationManager;
|
|
|
|
import org.wso2.carbon.user.api.UserRealm;
|
|
|
|
import org.wso2.carbon.user.api.UserRealm;
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
import org.wso2.carbon.user.api.UserStoreManager;
|
|
|
|
import org.wso2.carbon.user.api.UserStoreManager;
|
|
|
@ -148,7 +150,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException {
|
|
|
|
public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupAlreadyExistException, GroupManagementException {
|
|
|
|
if (groups == null) {
|
|
|
|
if (groups == null) {
|
|
|
|
String msg = "Received incomplete data for createGroup";
|
|
|
|
String msg = "Received incomplete data for createGroup";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
@ -181,7 +183,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new GroupManagementException("Group exist with name " + groups.getName());
|
|
|
|
throw new GroupAlreadyExistException("Group already exists with name : " + groups.getName() + " Try with another group name.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
@ -359,6 +361,40 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void deleteRoleAndRoleGroupMapping(String roleName, String roleToDelete, int tenantId, UserStoreManager userStoreManager, AuthorizationManager authorizationManager) throws GroupManagementException {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Delete roles");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
groupDAO.deleteGroupsMapping(roleToDelete, tenantId);
|
|
|
|
|
|
|
|
userStoreManager.deleteRole(roleName);
|
|
|
|
|
|
|
|
// Delete all authorizations for the current role before deleting
|
|
|
|
|
|
|
|
authorizationManager.clearRoleAuthorization(roleName);
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
String msg = "Error occurred while deleting the role '" + roleName + "'";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GroupManagementException(msg, e);
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while initiating transaction.";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GroupManagementException(msg, e);
|
|
|
|
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
String msg = "Error occurred while deleting the role";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GroupManagementException(msg, e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|