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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations