use of org.olat.commons.info.InfoMessageFrontendManager in project OpenOLAT by OpenOLAT.
the class InfoMessagesWebService method createEmptyCourse.
/**
* Creates a new info message
* @response.representation.200.qname {http://www.example.com}infoMessageVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The info message
* @response.representation.200.example {@link org.olat.commons.info.restapi.Examples#SAMPLE_INFOMESSAGEVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param resName The OLAT Resourceable name
* @param resId The OLAT Resourceable id
* @param resSubPath The resource sub path (optional)
* @param businessPath The business path
* @param authorKey The identity key of the author
* @param title The title
* @param message The message
* @param request The HTTP request
* @return It returns the id of the newly info message
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response createEmptyCourse(@QueryParam("resName") final String resName, @QueryParam("resId") final Long resId, @QueryParam("resSubPath") String resSubPath, @QueryParam("businessPath") String businessPath, @QueryParam("authorKey") Long authorKey, @QueryParam("title") String title, @QueryParam("message") String message, @Context HttpServletRequest request) {
if (!isAuthor(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
OLATResourceable ores = new OLATResourceable() {
@Override
public String getResourceableTypeName() {
return resName;
}
@Override
public Long getResourceableId() {
return resId;
}
};
Identity author;
UserRequest ureq = getUserRequest(request);
if (authorKey == null) {
author = ureq.getIdentity();
} else {
BaseSecurity securityManager = BaseSecurityManager.getInstance();
author = securityManager.loadIdentityByKey(authorKey, false);
if (author == null) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
}
InfoMessageFrontendManager messageManager = CoreSpringFactory.getImpl(InfoMessageFrontendManager.class);
InfoMessage msg = messageManager.createInfoMessage(ores, resSubPath, businessPath, author);
msg.setTitle(title);
msg.setMessage(message);
messageManager.sendInfoMessage(msg, null, ureq.getLocale(), ureq.getIdentity(), Collections.<Identity>emptyList());
InfoMessageVO infoVO = new InfoMessageVO(msg);
return Response.ok(infoVO).build();
}
use of org.olat.commons.info.InfoMessageFrontendManager in project OpenOLAT by OpenOLAT.
the class InfoMessagesWebService method getInfoMessageWebservice.
@Path("{infoMessageKey}")
public InfoMessageWebService getInfoMessageWebservice(@PathParam("infoMessageKey") Long infoMessageKey) {
InfoMessageFrontendManager messageManager = CoreSpringFactory.getImpl(InfoMessageFrontendManager.class);
InfoMessage msg = messageManager.loadInfoMessage(infoMessageKey);
return new InfoMessageWebService(msg);
}
use of org.olat.commons.info.InfoMessageFrontendManager in project OpenOLAT by OpenOLAT.
the class InfoCourseNode method cleanupOnDelete.
@Override
public /**
* is called when deleting this node, clean up info-messages and subscriptions!
*/
void cleanupOnDelete(ICourse course) {
super.cleanupOnDelete(course);
// delete infoMessages and subscriptions (OLAT-6171)
String resSubpath = getIdent();
InfoMessageFrontendManager infoService = CoreSpringFactory.getImpl(InfoMessageFrontendManager.class);
List<InfoMessage> messages = infoService.loadInfoMessageByResource(course, resSubpath, null, null, null, 0, 0);
for (InfoMessage im : messages) {
infoService.deleteInfoMessage(im);
}
final SubscriptionContext subscriptionContext = CourseModule.createTechnicalSubscriptionContext(course.getCourseEnvironment(), this);
NotificationsManager notifManagar = NotificationsManager.getInstance();
notifManagar.delete(subscriptionContext);
super.cleanupOnDelete(course);
}
use of org.olat.commons.info.InfoMessageFrontendManager in project openolat by klemens.
the class InfoMessagesWebService method createEmptyCourse.
/**
* Creates a new info message
* @response.representation.200.qname {http://www.example.com}infoMessageVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The info message
* @response.representation.200.example {@link org.olat.commons.info.restapi.Examples#SAMPLE_INFOMESSAGEVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param resName The OLAT Resourceable name
* @param resId The OLAT Resourceable id
* @param resSubPath The resource sub path (optional)
* @param businessPath The business path
* @param authorKey The identity key of the author
* @param title The title
* @param message The message
* @param request The HTTP request
* @return It returns the id of the newly info message
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response createEmptyCourse(@QueryParam("resName") final String resName, @QueryParam("resId") final Long resId, @QueryParam("resSubPath") String resSubPath, @QueryParam("businessPath") String businessPath, @QueryParam("authorKey") Long authorKey, @QueryParam("title") String title, @QueryParam("message") String message, @Context HttpServletRequest request) {
if (!isAuthor(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
OLATResourceable ores = new OLATResourceable() {
@Override
public String getResourceableTypeName() {
return resName;
}
@Override
public Long getResourceableId() {
return resId;
}
};
Identity author;
UserRequest ureq = getUserRequest(request);
if (authorKey == null) {
author = ureq.getIdentity();
} else {
BaseSecurity securityManager = BaseSecurityManager.getInstance();
author = securityManager.loadIdentityByKey(authorKey, false);
if (author == null) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
}
InfoMessageFrontendManager messageManager = CoreSpringFactory.getImpl(InfoMessageFrontendManager.class);
InfoMessage msg = messageManager.createInfoMessage(ores, resSubPath, businessPath, author);
msg.setTitle(title);
msg.setMessage(message);
messageManager.sendInfoMessage(msg, null, ureq.getLocale(), ureq.getIdentity(), Collections.<Identity>emptyList());
InfoMessageVO infoVO = new InfoMessageVO(msg);
return Response.ok(infoVO).build();
}
use of org.olat.commons.info.InfoMessageFrontendManager in project openolat by klemens.
the class InfoMessagesWebService method getInfoMessageWebservice.
@Path("{infoMessageKey}")
public InfoMessageWebService getInfoMessageWebservice(@PathParam("infoMessageKey") Long infoMessageKey) {
InfoMessageFrontendManager messageManager = CoreSpringFactory.getImpl(InfoMessageFrontendManager.class);
InfoMessage msg = messageManager.loadInfoMessage(infoMessageKey);
return new InfoMessageWebService(msg);
}
Aggregations