Search in sources :

Example 6 with Permissions

use of io.gravitee.rest.api.portal.rest.security.Permissions in project gravitee-management-rest-api by gravitee-io.

the class ApplicationLogsResource method applicationLog.

@GET
@Path("/{logId}")
@Produces(MediaType.APPLICATION_JSON)
@Permissions({ @Permission(value = RolePermission.APPLICATION_LOG, acls = RolePermissionAction.READ) })
public Response applicationLog(@PathParam("applicationId") String applicationId, @PathParam("logId") String logId, @QueryParam("timestamp") Long timestamp) {
    // Does application exists ?
    applicationService.findById(applicationId);
    ApplicationRequest applicationLogs = logsService.findApplicationLog(logId, timestamp);
    return Response.ok(logMapper.convert(applicationLogs)).build();
}
Also used : ApplicationRequest(io.gravitee.rest.api.model.log.ApplicationRequest) Permissions(io.gravitee.rest.api.portal.rest.security.Permissions)

Example 7 with Permissions

use of io.gravitee.rest.api.portal.rest.security.Permissions in project gravitee-management-rest-api by gravitee-io.

the class ApplicationMembersResource method createApplicationMember.

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Permissions({ @Permission(value = RolePermission.APPLICATION_MEMBER, acls = RolePermissionAction.CREATE) })
public Response createApplicationMember(@PathParam("applicationId") String applicationId, @Valid @NotNull(message = "Input must not be null.") MemberInput memberInput) {
    // Does application exist ?
    applicationService.findById(applicationId);
    // There can be only one
    if (SystemRole.PRIMARY_OWNER.name().equals(memberInput.getRole())) {
        throw new SinglePrimaryOwnerException(RoleScope.APPLICATION);
    }
    MemberEntity membership = membershipService.addRoleToMemberOnReference(new MembershipService.MembershipReference(MembershipReferenceType.APPLICATION, applicationId), new MembershipService.MembershipMember(memberInput.getUser(), memberInput.getReference(), MembershipMemberType.USER), new MembershipService.MembershipRole(RoleScope.APPLICATION, memberInput.getRole()));
    return Response.created(this.getLocationHeader(membership.getId())).entity(memberMapper.convert(membership, uriInfo)).build();
}
Also used : SinglePrimaryOwnerException(io.gravitee.rest.api.service.exceptions.SinglePrimaryOwnerException) MembershipService(io.gravitee.rest.api.service.MembershipService) MemberEntity(io.gravitee.rest.api.model.MemberEntity) Permissions(io.gravitee.rest.api.portal.rest.security.Permissions)

Example 8 with Permissions

use of io.gravitee.rest.api.portal.rest.security.Permissions in project gravitee-management-rest-api by gravitee-io.

the class ApplicationMembersResource method getApplicationMemberByApplicationIdAndMemberId.

@GET
@Path("/{memberId}")
@Produces(MediaType.APPLICATION_JSON)
@Permissions({ @Permission(value = RolePermission.APPLICATION_MEMBER, acls = RolePermissionAction.READ) })
public Response getApplicationMemberByApplicationIdAndMemberId(@PathParam("applicationId") String applicationId, @PathParam("memberId") String memberId) {
    // Does application exist ?
    applicationService.findById(applicationId);
    // Does user exist ?
    userService.findById(memberId);
    MemberEntity memberEntity = membershipService.getUserMember(MembershipReferenceType.APPLICATION, applicationId, memberId);
    if (memberEntity != null) {
        return Response.ok(memberMapper.convert(memberEntity, uriInfo)).build();
    }
    throw new NotFoundException();
}
Also used : MemberEntity(io.gravitee.rest.api.model.MemberEntity) Permissions(io.gravitee.rest.api.portal.rest.security.Permissions)

Example 9 with Permissions

use of io.gravitee.rest.api.portal.rest.security.Permissions in project gravitee-management-rest-api by gravitee-io.

the class ApplicationMembersResource method updateApplicationMemberByApplicationIdAndMemberId.

@PUT
@Path("/{memberId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Permissions({ @Permission(value = RolePermission.APPLICATION_MEMBER, acls = RolePermissionAction.UPDATE) })
public Response updateApplicationMemberByApplicationIdAndMemberId(@PathParam("applicationId") String applicationId, @PathParam("memberId") String memberId, @Valid @NotNull(message = "Input must not be null.") MemberInput memberInput) {
    // Does application exist ?
    applicationService.findById(applicationId);
    // Does user exist ?
    userService.findById(memberId);
    if (memberInput.getUser() != null && !memberId.equals(memberInput.getUser())) {
        throw new BadRequestException("'memberInput.user' should the same as 'memberId'");
    }
    // There can be only one
    if (SystemRole.PRIMARY_OWNER.name().equals(memberInput.getRole())) {
        throw new SinglePrimaryOwnerException(RoleScope.APPLICATION);
    }
    MemberEntity membership = membershipService.updateRoleToMemberOnReference(new MembershipService.MembershipReference(MembershipReferenceType.APPLICATION, applicationId), new MembershipService.MembershipMember(memberId, memberInput.getReference(), MembershipMemberType.USER), new MembershipService.MembershipRole(RoleScope.APPLICATION, memberInput.getRole()));
    return Response.ok(memberMapper.convert(membership, uriInfo)).build();
}
Also used : SinglePrimaryOwnerException(io.gravitee.rest.api.service.exceptions.SinglePrimaryOwnerException) MembershipService(io.gravitee.rest.api.service.MembershipService) MemberEntity(io.gravitee.rest.api.model.MemberEntity) Permissions(io.gravitee.rest.api.portal.rest.security.Permissions)

Example 10 with Permissions

use of io.gravitee.rest.api.portal.rest.security.Permissions in project gravitee-management-rest-api by gravitee-io.

the class ApplicationNotificationResource method update.

@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Permissions({ @Permission(value = RolePermission.APPLICATION_NOTIFICATION, acls = RolePermissionAction.UPDATE) })
public Response update(@PathParam("applicationId") String applicationId, @NotNull(message = "Input must not be null.") NotificationInput notification) {
    // Does application exists ?
    applicationService.findById(applicationId);
    final PortalNotificationConfigEntity portalConfig = portalNotificationConfigService.findById(getAuthenticatedUser(), NotificationReferenceType.APPLICATION, applicationId);
    portalConfig.setHooks(notification.getHooks());
    portalNotificationConfigService.save(portalConfig);
    genericNotificationConfigService.findByReference(NotificationReferenceType.APPLICATION, applicationId).forEach(genericConfig -> {
        genericConfig.setHooks(notification.getHooks());
        genericNotificationConfigService.update(genericConfig);
    });
    return Response.ok(notification.getHooks()).build();
}
Also used : PortalNotificationConfigEntity(io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity) Permissions(io.gravitee.rest.api.portal.rest.security.Permissions)

Aggregations

Permissions (io.gravitee.rest.api.portal.rest.security.Permissions)20 RatingEntity (io.gravitee.rest.api.model.RatingEntity)5 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)5 ApiQuery (io.gravitee.rest.api.model.api.ApiQuery)5 ApiNotFoundException (io.gravitee.rest.api.service.exceptions.ApiNotFoundException)5 RatingNotFoundException (io.gravitee.rest.api.service.exceptions.RatingNotFoundException)4 ApplicationEntity (io.gravitee.rest.api.model.ApplicationEntity)3 MemberEntity (io.gravitee.rest.api.model.MemberEntity)3 Produces (javax.ws.rs.Produces)3 InlinePictureEntity (io.gravitee.rest.api.model.InlinePictureEntity)2 UpdateApplicationEntity (io.gravitee.rest.api.model.UpdateApplicationEntity)2 UpdateRatingEntity (io.gravitee.rest.api.model.UpdateRatingEntity)2 AlertTriggerEntity (io.gravitee.rest.api.model.alert.AlertTriggerEntity)2 ApplicationSettings (io.gravitee.rest.api.model.application.ApplicationSettings)2 OAuthClientSettings (io.gravitee.rest.api.model.application.OAuthClientSettings)2 SimpleApplicationSettings (io.gravitee.rest.api.model.application.SimpleApplicationSettings)2 PortalNotificationConfigEntity (io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity)2 MembershipService (io.gravitee.rest.api.service.MembershipService)2 SinglePrimaryOwnerException (io.gravitee.rest.api.service.exceptions.SinglePrimaryOwnerException)2 Consumes (javax.ws.rs.Consumes)2