Juan Hernandez has uploaded a new change for review. Change subject: restapi: Add system permissions resource ......................................................................
restapi: Add system permissions resource Currently there is no resource to manage system permissions directly, they are managed indirectly using the users and groups resources. This patch adds a new resource avaiable in /api/permissions that will handle these permissions. Change-Id: I3119384b3e7036b0d793a71739d77a1ac5a9cf44 Bug-Url: https://bugzilla.redhat.com/1018552 Signed-off-by: Juan Hernandez <[email protected]> --- M backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/util/LinkHelper.java A backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/SystemPermissionsResource.java M backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/BackendApplication.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendApiResource.java A backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSystemPermissionsResource.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendApiResourceTest.java M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermissionMapper.java 8 files changed, 124 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/57/20357/1 diff --git a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/util/LinkHelper.java b/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/util/LinkHelper.java index 87618aa..fbfa921 100644 --- a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/util/LinkHelper.java +++ b/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/util/LinkHelper.java @@ -139,6 +139,7 @@ import org.ovirt.engine.api.resource.StorageResource; import org.ovirt.engine.api.resource.StorageServerConnectionResource; import org.ovirt.engine.api.resource.StorageServerConnectionsResource; +import org.ovirt.engine.api.resource.SystemPermissionsResource; import org.ovirt.engine.api.resource.TagResource; import org.ovirt.engine.api.resource.TagsResource; import org.ovirt.engine.api.resource.TemplateDiskResource; @@ -259,6 +260,7 @@ map.add(PermissionResource.class, AssignedPermissionsResource.class, Role.class); map.add(PermissionResource.class, AssignedPermissionsResource.class, VM.class); map.add(PermissionResource.class, AssignedPermissionsResource.class, Disk.class); + map.add(PermissionResource.class, SystemPermissionsResource.class, NO_PARENT); TYPES.put(Permission.class, map); map = new ParentToCollectionMap(NetworkResource.class, NetworksResource.class); @@ -679,7 +681,6 @@ * * @param uriInfo the URI info * @param model the object - * @param suggestedParentType the suggested parent type * @return the object, with href attributes and action links */ public static <R extends BaseResource> R addLinks(UriInfo uriInfo, R model) { @@ -749,7 +750,6 @@ /** * Appends searchable links to resource's Href * - * @param url to append to and combine search dialect * @param resource to add links to * @param rel link ro add */ diff --git a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/SystemPermissionsResource.java b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/SystemPermissionsResource.java new file mode 100644 index 0000000..02858f9 --- /dev/null +++ b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/SystemPermissionsResource.java @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2013 Red Hat, Inc. +* +* 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 org.ovirt.engine.api.resource; + +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +@Path("/permissions") +@Produces({ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML}) +public interface SystemPermissionsResource extends AssignedPermissionsResource { + // This interface doesn't add any new methods, it is just a placeholder for the annotation that specifies the path + // of the resource that manages the permissions assigned to the system object. +} diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml index f595bdb..abc89a1 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml @@ -4313,3 +4313,48 @@ Content-Type: {value: application/xml|json, required: true} Correlation-Id: {value: 'any string', required: false} +- name: /api/permissions|rel=get + description: get the list of permissions on the system + request: + body: + parameterType: null + signatures: [] + urlparams: + max: {context: matrix, type: 'xs:int', value: 'max results', required: false} + headers: {} +- name: /api/permissions/{permission:id}|rel=get + description: get the details of the permission on the system + request: + body: + parameterType: null + signatures: [] + urlparams: {} + headers: {} +- name: /api/permissions/{permission:id}|rel=delete + description: delete the permission on the system + request: + body: + parameterType: null + signatures: [] + urlparams: + async: {context: matrix, type: 'xs:boolean', value: true|false, required: false} + headers: + Correlation-Id: {value: 'any string', required: false} +- name: /api/permissions|rel=add + description: add a new permission on the system + request: + body: + parameterType: Permission + signatures: + - mandatoryArguments: {permission.user.id: 'xs:string', permission.role.id: 'xs:string'} + optionalArguments: {} + description: add a new user level permission on the system + - mandatoryArguments: {permission.role.id: 'xs:string', permission.group.id: 'xs:string'} + optionalArguments: {} + description: add a new group level permission on the system + urlparams: {} + headers: + Content-Type: {value: application/xml|json, required: true} + Expect: {value: 201-created, required: false} + Correlation-Id: {value: 'any string', required: false} + diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/BackendApplication.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/BackendApplication.java index 40b3e9e..8dea70d 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/BackendApplication.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/BackendApplication.java @@ -51,6 +51,7 @@ import org.ovirt.engine.api.restapi.resource.BackendRolesResource; import org.ovirt.engine.api.restapi.resource.BackendStorageDomainsResource; import org.ovirt.engine.api.restapi.resource.BackendStorageServerConnectionsResource; +import org.ovirt.engine.api.restapi.resource.BackendSystemPermissionsResource; import org.ovirt.engine.api.restapi.resource.BackendTagsResource; import org.ovirt.engine.api.restapi.resource.BackendTemplatesResource; import org.ovirt.engine.api.restapi.resource.BackendUsersResource; @@ -135,6 +136,7 @@ addResource(new BackendJobsResource()); addResource(new BackendStorageServerConnectionsResource()); addResource(new BackendVnicProfilesResource()); + addResource(new BackendSystemPermissionsResource()); addResource(VmHelper.getInstance()); // Authentication singletons: diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendApiResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendApiResource.java index f5eb3f7..d0077e2 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendApiResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendApiResource.java @@ -120,6 +120,7 @@ links.add(createLink("jobs")); links.add(createLink("storageconnections")); links.add(createLink("vnicprofiles")); + links.add(createLink("permissions")); return links; } diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSystemPermissionsResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSystemPermissionsResource.java new file mode 100644 index 0000000..408cae1 --- /dev/null +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSystemPermissionsResource.java @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2013 Red Hat, Inc. +* +* 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 org.ovirt.engine.api.restapi.resource; + +import org.ovirt.engine.api.model.BaseResource; +import org.ovirt.engine.api.resource.SystemPermissionsResource; +import org.ovirt.engine.core.common.VdcObjectType; +import org.ovirt.engine.core.common.queries.GetPermissionsForObjectParameters; +import org.ovirt.engine.core.common.queries.VdcQueryType; +import org.ovirt.engine.core.compat.Guid; + +/** + * This resource corresponds to the permissions assigned to the system object. + */ +public class BackendSystemPermissionsResource extends BackendAssignedPermissionsResource + implements SystemPermissionsResource{ + + public BackendSystemPermissionsResource() { + super( + Guid.SYSTEM, + VdcQueryType.GetPermissionsForObject, + new GetPermissionsForObjectParameters(Guid.SYSTEM), + BaseResource.class, + VdcObjectType.System + ); + } + +} diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendApiResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendApiResourceTest.java index 46f153d..74a042b 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendApiResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendApiResourceTest.java @@ -119,6 +119,7 @@ "jobs", "storageconnections", "vnicprofiles", + "permissions", }; private static final String[] relationshipsGlusterOnly = { @@ -171,7 +172,8 @@ BASE_PATH + "/disks?search={query}", BASE_PATH + "/jobs", BASE_PATH + "/storageconnections", - BASE_PATH + "/vnicprofiles" + BASE_PATH + "/vnicprofiles", + BASE_PATH + "/permissions" }; private static final String[] hrefsGlusterOnly = { diff --git a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermissionMapper.java b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermissionMapper.java index b3b54ae..8e691a1 100644 --- a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermissionMapper.java +++ b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermissionMapper.java @@ -107,8 +107,9 @@ private static void setObjectId(Permission model, permissions entity) { String id = entity.getObjectId().toString(); switch (entity.getObjectType()) { + case System: + break; case StoragePool : - case System : model.setDataCenter(new DataCenter()); model.getDataCenter().setId(id); break; -- To view, visit http://gerrit.ovirt.org/20357 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3119384b3e7036b0d793a71739d77a1ac5a9cf44 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
