mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fixed issues in scope service
This commit is contained in:
parent
b8f2457046
commit
b3d309583d
@ -110,14 +110,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cxf</groupId>
|
<groupId>org.apache.cxf</groupId>
|
||||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cxf</groupId>
|
<groupId>org.apache.cxf</groupId>
|
||||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cxf</groupId>
|
<groupId>org.apache.cxf</groupId>
|
||||||
<artifactId>cxf-rt-transports-http</artifactId>
|
<artifactId>cxf-rt-transports-http</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
@ -237,17 +240,18 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
<artifactId>org.wso2.carbon.device.mgt.analytics.dashboard</artifactId>
|
<artifactId>org.wso2.carbon.device.mgt.analytics.dashboard</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!--<dependency>-->
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<!--<groupId>com.fasterxml.jackson.core</groupId>-->
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<!--<artifactId>jackson-annotations</artifactId>-->
|
||||||
<scope>provided</scope>
|
<!--<scope>provided</scope>-->
|
||||||
</dependency>
|
<!--</dependency>-->
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -20,8 +20,6 @@ package org.wso2.carbon.device.mgt.jaxrs.beans;
|
|||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.wso2.carbon.apimgt.api.model.Scope;
|
|
||||||
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -32,7 +30,7 @@ public class RoleInfo {
|
|||||||
@ApiModelProperty(name = "roleName", value = "The name of the role.", required = true)
|
@ApiModelProperty(name = "roleName", value = "The name of the role.", required = true)
|
||||||
private String roleName;
|
private String roleName;
|
||||||
@ApiModelProperty(name = "scopes", value = "Lists out all the scopes associated with roles.",
|
@ApiModelProperty(name = "scopes", value = "Lists out all the scopes associated with roles.",
|
||||||
required = true, dataType = "List[Scope]")
|
required = true, dataType = "List[org.wso2.carbon.device.mgt.jaxrs.beans.Scope]")
|
||||||
private List<Scope> scopes;
|
private List<Scope> scopes;
|
||||||
@ApiModelProperty(name = "users", value = "The list of users assigned to the selected role.",
|
@ApiModelProperty(name = "users", value = "The list of users assigned to the selected role.",
|
||||||
required = true, dataType = "List[java.lang.String]")
|
required = true, dataType = "List[java.lang.String]")
|
||||||
|
|||||||
@ -21,11 +21,10 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
|||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||||
import org.wso2.carbon.apimgt.api.model.Scope;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
|
||||||
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.Scope;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
@ -125,7 +124,7 @@ public interface RoleManagementService {
|
|||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 200,
|
code = 200,
|
||||||
message = "OK. \n Successfully fetched the scopes list.",
|
message = "OK. \n Successfully fetched the scopes list.",
|
||||||
response = UIPermissionNode.class,
|
response = List.class,
|
||||||
responseContainer = "List",
|
responseContainer = "List",
|
||||||
responseHeaders = {
|
responseHeaders = {
|
||||||
@ResponseHeader(
|
@ResponseHeader(
|
||||||
|
|||||||
@ -20,23 +20,22 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
|||||||
|
|
||||||
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.wso2.carbon.CarbonConstants;
|
|
||||||
import org.wso2.carbon.apimgt.api.model.Scope;
|
|
||||||
import org.wso2.carbon.base.MultitenantConstants;
|
|
||||||
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementException;
|
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementService;
|
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.Scope;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.RoleManagementService;
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.RoleManagementService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.FilteringUtil;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.FilteringUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.SetReferenceTransformer;
|
import org.wso2.carbon.device.mgt.jaxrs.util.SetReferenceTransformer;
|
||||||
import org.wso2.carbon.user.api.*;
|
import org.wso2.carbon.user.api.AuthorizationManager;
|
||||||
import org.wso2.carbon.user.mgt.UserRealmProxy;
|
import org.wso2.carbon.user.api.UserRealm;
|
||||||
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
import org.wso2.carbon.user.api.UserStoreException;
|
||||||
import org.wso2.carbon.user.mgt.common.UserAdminException;
|
import org.wso2.carbon.user.api.UserStoreManager;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
@ -93,7 +92,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
|||||||
if (scopeManagementService == null) {
|
if (scopeManagementService == null) {
|
||||||
log.error("Scope management service initialization is failed, hence scopes will not be retrieved");
|
log.error("Scope management service initialization is failed, hence scopes will not be retrieved");
|
||||||
} else {
|
} else {
|
||||||
scopes = scopeManagementService.getAllScopes();
|
scopes = DeviceMgtUtil.convertAPIScopestoScopes(scopeManagementService.getAllScopes());
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(scopes).build();
|
return Response.status(Response.Status.OK).entity(scopes).build();
|
||||||
} catch (ScopeManagementException e) {
|
} catch (ScopeManagementException e) {
|
||||||
@ -114,9 +113,9 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
|||||||
if (scopeManagementService == null) {
|
if (scopeManagementService == null) {
|
||||||
log.error("Scope management service initialization is failed, hence scopes will not be retrieved");
|
log.error("Scope management service initialization is failed, hence scopes will not be retrieved");
|
||||||
} else {
|
} else {
|
||||||
scopeManagementService.updateScopes(scopes);
|
scopeManagementService.updateScopes(DeviceMgtUtil.convertScopestoAPIScopes(scopes));
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(scopes).build();
|
return Response.status(Response.Status.OK).entity("Scopes has been successfully updated").build();
|
||||||
} catch (ScopeManagementException e) {
|
} catch (ScopeManagementException e) {
|
||||||
String msg = "Error occurred while updating the scopes";
|
String msg = "Error occurred while updating the scopes";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
@ -226,7 +225,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
|||||||
if (scopeManagementService == null) {
|
if (scopeManagementService == null) {
|
||||||
log.error("Scope management service initialization is failed, hence scopes will not be updated");
|
log.error("Scope management service initialization is failed, hence scopes will not be updated");
|
||||||
} else {
|
} else {
|
||||||
scopeManagementService.updateScopes(roleInfo.getScopes());
|
scopeManagementService.updateScopes(DeviceMgtUtil.convertScopestoAPIScopes(roleInfo.getScopes()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO: Need to send the updated role information in the entity back to the client
|
//TODO: Need to send the updated role information in the entity back to the client
|
||||||
@ -274,7 +273,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
|||||||
if (scopeManagementService == null) {
|
if (scopeManagementService == null) {
|
||||||
log.error("Scope management service initialization is failed, hence scopes will not be updated");
|
log.error("Scope management service initialization is failed, hence scopes will not be updated");
|
||||||
} else {
|
} else {
|
||||||
scopeManagementService.updateScopes(roleInfo.getScopes());
|
scopeManagementService.updateScopes(DeviceMgtUtil.convertScopestoAPIScopes(roleInfo.getScopes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.status(Response.Status.OK).build();
|
return Response.status(Response.Status.OK).build();
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.service.impl.util;
|
package org.wso2.carbon.device.mgt.jaxrs.service.impl.util;
|
||||||
|
|
||||||
import org.wso2.carbon.apimgt.api.model.Scope;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.Scope;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
|
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.util;
|
package org.wso2.carbon.device.mgt.jaxrs.util;
|
||||||
|
|
||||||
|
import org.wso2.carbon.apimgt.api.model.Scope;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ProfileFeature;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ProfileFeature;
|
||||||
import org.wso2.carbon.policy.mgt.common.Profile;
|
import org.wso2.carbon.policy.mgt.common.Profile;
|
||||||
|
|
||||||
@ -58,4 +59,32 @@ public class DeviceMgtUtil {
|
|||||||
return profileFeature;
|
return profileFeature;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Scope> convertScopestoAPIScopes(List<org.wso2.carbon.device.mgt.jaxrs.beans.Scope> scopes) {
|
||||||
|
List<Scope> convertedScopes = new ArrayList<>();
|
||||||
|
Scope convertedScope;
|
||||||
|
for (org.wso2.carbon.device.mgt.jaxrs.beans.Scope scope : scopes) {
|
||||||
|
convertedScope = new Scope();
|
||||||
|
convertedScope.setKey(scope.getKey());
|
||||||
|
convertedScope.setName(scope.getName());
|
||||||
|
convertedScope.setDescription(scope.getDescription());
|
||||||
|
convertedScope.setRoles(scope.getRoles());
|
||||||
|
convertedScopes.add(convertedScope);
|
||||||
|
}
|
||||||
|
return convertedScopes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<org.wso2.carbon.device.mgt.jaxrs.beans.Scope> convertAPIScopestoScopes(List<Scope> scopes) {
|
||||||
|
List<org.wso2.carbon.device.mgt.jaxrs.beans.Scope> convertedScopes = new ArrayList<>();
|
||||||
|
org.wso2.carbon.device.mgt.jaxrs.beans.Scope convertedScope;
|
||||||
|
for (Scope scope : scopes) {
|
||||||
|
convertedScope = new org.wso2.carbon.device.mgt.jaxrs.beans.Scope();
|
||||||
|
convertedScope.setKey(scope.getKey());
|
||||||
|
convertedScope.setName(scope.getName());
|
||||||
|
convertedScope.setDescription(scope.getDescription());
|
||||||
|
convertedScope.setRoles(scope.getRoles());
|
||||||
|
convertedScopes.add(convertedScope);
|
||||||
|
}
|
||||||
|
return convertedScopes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<property name="version" value="1.0"/>
|
<property name="version" value="1.0"/>
|
||||||
<property name="host" value="localhost:9443"/>
|
<property name="host" value="localhost:9443"/>
|
||||||
<property name="schemes" value="https" />
|
<property name="schemes" value="https" />
|
||||||
<property name="basePath" value="/api-device-mgt-v1.0"/>
|
<property name="basePath" value="/api/device-mgt/v1.0"/>
|
||||||
<property name="title" value="Device Management Admin Service API Definitions"/>
|
<property name="title" value="Device Management Admin Service API Definitions"/>
|
||||||
<property name="contact" value="dev@wso2.org"/>
|
<property name="contact" value="dev@wso2.org"/>
|
||||||
<property name="license" value="Apache 2.0"/>
|
<property name="license" value="Apache 2.0"/>
|
||||||
|
|||||||
@ -50,6 +50,7 @@
|
|||||||
<Import-Package>
|
<Import-Package>
|
||||||
javax.xml.bind.annotation,
|
javax.xml.bind.annotation,
|
||||||
com.fasterxml.jackson.annotation,
|
com.fasterxml.jackson.annotation,
|
||||||
|
org.wso2.carbon.apimgt.api.model,
|
||||||
io.swagger.annotations.*;resolution:=optional
|
io.swagger.annotations.*;resolution:=optional
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
</instructions>
|
</instructions>
|
||||||
|
|||||||
@ -73,7 +73,7 @@ public class ScopeManagementDAOImpl implements ScopeManagementDAO {
|
|||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
if (rs.next()) {
|
while (rs.next()) {
|
||||||
scope = new Scope();
|
scope = new Scope();
|
||||||
scope.setKey(rs.getString("SCOPE_KEY"));
|
scope.setKey(rs.getString("SCOPE_KEY"));
|
||||||
scope.setName(rs.getString("NAME"));
|
scope.setName(rs.getString("NAME"));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user