use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageSignature in project muikku by otavanopisto.
the class CommunicatorRESTService method deleteUserMessageSignature.
@DELETE
@Path("/signatures/{SIGNATUREID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response deleteUserMessageSignature(@PathParam("SIGNATUREID") Long signatureId) throws AuthorizationException {
CommunicatorMessageSignature messageSignature = communicatorController.getMessageSignature(signatureId);
if (!sessionController.hasPermission(CommunicatorPermissionCollection.COMMUNICATOR_MANAGE_SETTINGS, messageSignature)) {
return Response.status(Status.FORBIDDEN).build();
}
communicatorController.deleteMessageSignature(messageSignature);
return Response.noContent().build();
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageSignature in project muikku by otavanopisto.
the class CommunicatorRESTService method getUserMessageSignature.
@GET
@Path("/signatures/{SIGNATUREID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response getUserMessageSignature(@PathParam("SIGNATUREID") Long signatureId) throws AuthorizationException {
CommunicatorMessageSignature signature = communicatorController.getMessageSignature(signatureId);
if (!sessionController.hasPermission(CommunicatorPermissionCollection.COMMUNICATOR_MANAGE_SETTINGS, signature)) {
return Response.status(Status.FORBIDDEN).build();
}
CommunicatorMessageSignatureRESTModel result = new CommunicatorMessageSignatureRESTModel(signature.getId(), signature.getName(), signature.getSignature());
return Response.ok(result).build();
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageSignature in project muikku by otavanopisto.
the class CommunicatorRESTService method createUserMessageSignature.
@POST
@Path("/signatures")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response createUserMessageSignature(CommunicatorMessageSignatureRESTModel newSignature) throws AuthorizationException {
UserEntity userEntity = sessionController.getLoggedUserEntity();
CommunicatorMessageSignature messageSignature = communicatorController.createMessageSignature(newSignature.getName(), newSignature.getSignature(), userEntity);
CommunicatorMessageSignatureRESTModel result = new CommunicatorMessageSignatureRESTModel(messageSignature.getId(), messageSignature.getName(), messageSignature.getSignature());
return Response.ok(result).build();
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageSignature in project muikku by otavanopisto.
the class CommunicatorRESTService method listUserMessageSignatures.
@GET
@Path("/signatures")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listUserMessageSignatures() throws AuthorizationException {
UserEntity userEntity = sessionController.getLoggedUserEntity();
List<CommunicatorMessageSignature> signatures = communicatorController.listMessageSignatures(userEntity);
List<CommunicatorMessageSignatureRESTModel> result = new ArrayList<CommunicatorMessageSignatureRESTModel>();
for (CommunicatorMessageSignature signature : signatures) {
result.add(new CommunicatorMessageSignatureRESTModel(signature.getId(), signature.getName(), signature.getSignature()));
}
return Response.ok(result).build();
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageSignature in project muikku by otavanopisto.
the class CommunicatorRESTService method editUserMessageSignature.
@PUT
@Path("/signatures/{SIGNATUREID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response editUserMessageSignature(@PathParam("SIGNATUREID") Long signatureId, CommunicatorMessageSignatureRESTModel signature) throws AuthorizationException {
if (!signature.getId().equals(signatureId)) {
return Response.status(Response.Status.BAD_REQUEST).entity("Id is immutable").build();
}
CommunicatorMessageSignature messageSignature = communicatorController.getMessageSignature(signatureId);
if (!sessionController.hasPermission(CommunicatorPermissionCollection.COMMUNICATOR_MANAGE_SETTINGS, messageSignature)) {
return Response.status(Status.FORBIDDEN).build();
}
CommunicatorMessageSignature editMessageSignature = communicatorController.editMessageSignature(messageSignature, signature.getName(), signature.getSignature());
CommunicatorMessageSignatureRESTModel result = new CommunicatorMessageSignatureRESTModel(editMessageSignature.getId(), editMessageSignature.getName(), editMessageSignature.getSignature());
return Response.ok(result).build();
}
Aggregations