use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.
the class StaffRESTService method listStaffMemberPhoneNumbers.
@Path("/members/{STAFFMEMBERID:[0-9]*}/phoneNumbers")
@GET
@RESTPermit(handling = Handling.INLINE)
public Response listStaffMemberPhoneNumbers(@PathParam("STAFFMEMBERID") Long staffMemberId) {
StaffMember staffMember = userController.findStaffMemberById(staffMemberId);
if (staffMember == null) {
return Response.status(Status.NOT_FOUND).build();
}
if (staffMember.getArchived()) {
return Response.status(Status.NOT_FOUND).build();
}
if (!restSecurity.hasPermission(new String[] { UserPermissions.LIST_STAFFMEMBERPHONENUMBERS }, staffMember) && !restSecurity.hasPermission(new String[] { PersonPermissions.PERSON_OWNER }, staffMember.getPerson())) {
return Response.status(Status.FORBIDDEN).build();
}
List<PhoneNumber> phoneNumbers = staffMember.getContactInfo().getPhoneNumbers();
if (phoneNumbers.isEmpty()) {
return Response.noContent().build();
}
return Response.ok(objectFactory.createModel(phoneNumbers)).build();
}
use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.
the class StaffRESTService method findStaffMemberPhoneNumber.
@Path("/members/{STAFFMEMBERID:[0-9]*}/phoneNumbers/{ID:[0-9]*}")
@GET
@RESTPermit(handling = Handling.INLINE)
public Response findStaffMemberPhoneNumber(@PathParam("STAFFMEMBERID") Long staffMemberId, @PathParam("ID") Long id) {
StaffMember staffMember = userController.findStaffMemberById(staffMemberId);
if (staffMember == null) {
return Response.status(Status.NOT_FOUND).build();
}
if (staffMember.getArchived()) {
return Response.status(Status.NOT_FOUND).build();
}
if (!restSecurity.hasPermission(new String[] { UserPermissions.FIND_STAFFMEMBERPHONENUMBER }, staffMember) && !restSecurity.hasPermission(new String[] { PersonPermissions.PERSON_OWNER }, staffMember.getPerson())) {
return Response.status(Status.FORBIDDEN).build();
}
PhoneNumber phoneNumber = commonController.findPhoneNumberById(id);
if (phoneNumber == null) {
return Response.status(Status.NOT_FOUND).build();
}
if (!phoneNumber.getContactInfo().getId().equals(staffMember.getContactInfo().getId())) {
return Response.status(Status.NOT_FOUND).build();
}
return Response.ok(objectFactory.createModel(phoneNumber)).build();
}
use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.
the class StaffRESTService method listStaffMembersEmails.
@Path("/members/{ID:[0-9]*}/emails")
@GET
@RESTPermit(UserPermissions.LIST_STAFFMEMBER_EMAILS)
public Response listStaffMembersEmails(@PathParam("ID") Long id) {
StaffMember user = userController.findStaffMemberById(id);
if (user == null) {
return Response.status(Status.NOT_FOUND).build();
}
List<Email> emails = user.getContactInfo().getEmails();
if (emails.isEmpty()) {
return Response.noContent().build();
}
return Response.ok(objectFactory.createModel(emails)).build();
}
use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.
the class StaffRESTService method deleteStaffMemberAddress.
@Path("/members/{STAFFMEMBERID:[0-9]*}/addresses/{ID:[0-9]*}")
@DELETE
@RESTPermit(handling = Handling.INLINE)
public Response deleteStaffMemberAddress(@PathParam("STAFFMEMBERID") Long staffMemberId, @PathParam("ID") Long id) {
StaffMember staffMember = userController.findStaffMemberById(staffMemberId);
if (staffMember == null) {
return Response.status(Status.NOT_FOUND).build();
}
if (staffMember.getArchived()) {
return Response.status(Status.NOT_FOUND).build();
}
if (!restSecurity.hasPermission(new String[] { UserPermissions.DELETE_STAFFMEMBERADDRESS }, staffMember) && !restSecurity.hasPermission(new String[] { PersonPermissions.PERSON_OWNER }, staffMember.getPerson())) {
return Response.status(Status.FORBIDDEN).build();
}
Address address = commonController.findAddressById(id);
if (address == null) {
return Response.status(Status.NOT_FOUND).build();
}
if (!address.getContactInfo().getId().equals(staffMember.getContactInfo().getId())) {
return Response.status(Status.NOT_FOUND).build();
}
commonController.deleteAddress(address);
return Response.noContent().build();
}
use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.
the class StaffRESTService method deleteStaffMemberPhoneNumber.
@Path("/members/{STAFFMEMBERID:[0-9]*}/phoneNumbers/{ID:[0-9]*}")
@DELETE
@RESTPermit(handling = Handling.INLINE)
public Response deleteStaffMemberPhoneNumber(@PathParam("STAFFMEMBERID") Long staffMemberId, @PathParam("ID") Long id) {
StaffMember staffMember = userController.findStaffMemberById(staffMemberId);
if (staffMember == null) {
return Response.status(Status.NOT_FOUND).build();
}
if (staffMember.getArchived()) {
return Response.status(Status.NOT_FOUND).build();
}
if (!restSecurity.hasPermission(new String[] { UserPermissions.DELETE_STAFFMEMBERPHONENUMBER }, staffMember) && !restSecurity.hasPermission(new String[] { PersonPermissions.PERSON_OWNER }, staffMember.getPerson())) {
return Response.status(Status.FORBIDDEN).build();
}
PhoneNumber phoneNumber = commonController.findPhoneNumberById(id);
if (phoneNumber == null) {
return Response.status(Status.NOT_FOUND).build();
}
if (!phoneNumber.getContactInfo().getId().equals(staffMember.getContactInfo().getId())) {
return Response.status(Status.NOT_FOUND).build();
}
commonController.deletePhoneNumber(phoneNumber);
return Response.noContent().build();
}
Aggregations