use of org.springframework.web.bind.annotation.PostMapping in project dhis2-core by dhis2.
the class DataStatisticsController method saveEvent.
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public void saveEvent(@RequestParam DataStatisticsEventType eventType, String favorite) {
Date timestamp = new Date();
String username = currentUserService.getCurrentUsername();
DataStatisticsEvent event = new DataStatisticsEvent(eventType, timestamp, username, favorite);
dataStatisticsService.addEvent(event);
}
use of org.springframework.web.bind.annotation.PostMapping in project cas by apereo.
the class RegisteredServiceSimpleFormController method saveService.
/**
* Adds the service to the Service Registry.
*
* @param request the request
* @param response the response
* @param result the result
* @param service the edit bean
*/
@PostMapping(value = "saveService.html")
public void saveService(final HttpServletRequest request, final HttpServletResponse response, @RequestBody final RegisteredServiceEditBean.ServiceData service, final BindingResult result) {
try {
if (StringUtils.isNotBlank(service.getAssignedId())) {
final RegisteredService svc = this.servicesManager.findServiceBy(Long.parseLong(service.getAssignedId()));
if (svc != null) {
this.servicesManager.delete(svc.getId());
}
}
final RegisteredService svcToUse = this.registeredServiceFactory.createRegisteredService(service);
final RegisteredService newSvc = this.servicesManager.save(svcToUse);
LOGGER.info("Saved changes to service [{}]", svcToUse.getId());
final Map<String, Object> model = new HashMap<>();
model.put("id", newSvc.getId());
model.put("status", HttpServletResponse.SC_OK);
JsonUtils.render(model, response);
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
use of org.springframework.web.bind.annotation.PostMapping in project cas by apereo.
the class ManageRegisteredServicesMultiActionController method updateRegisteredServiceEvaluationOrder.
/**
* Updates the {@link RegisteredService#getEvaluationOrder()}.
*
* @param response the response
* @param id the service ids, whose order also determines the service evaluation order
*/
@PostMapping(value = "/updateRegisteredServiceEvaluationOrder")
public void updateRegisteredServiceEvaluationOrder(final HttpServletResponse response, @RequestParam("id") final long... id) {
if (id == null || id.length == 0) {
throw new IllegalArgumentException("No service id was received. Re-examine the request");
}
for (int i = 0; i < id.length; i++) {
final long svcId = id[i];
final RegisteredService svc = this.servicesManager.findServiceBy(svcId);
if (svc == null) {
throw new IllegalArgumentException("Service id " + svcId + " cannot be found.");
}
svc.setEvaluationOrder(i);
this.servicesManager.save(svc);
}
final Map<String, Object> model = new HashMap<>();
model.put(STATUS, HttpServletResponse.SC_OK);
JsonUtils.render(model, response);
}
use of org.springframework.web.bind.annotation.PostMapping in project cas by apereo.
the class ManageRegisteredServicesMultiActionController method deleteRegisteredService.
/**
* Method to delete the RegisteredService by its ID. Will make sure
* the default service that is the management app itself cannot be deleted
* or the user will be locked out.
*
* @param idAsLong the id
* @param response the response
*/
@PostMapping(value = "/deleteRegisteredService")
public void deleteRegisteredService(@RequestParam("id") final long idAsLong, final HttpServletResponse response) {
final RegisteredService svc = this.servicesManager.findServiceBy(this.defaultService);
if (svc == null || svc.getId() == idAsLong) {
throw new IllegalArgumentException("The default service " + this.defaultService.getId() + " cannot be deleted. " + "The definition is required for accessing the application.");
}
final RegisteredService r = this.servicesManager.delete(idAsLong);
if (r == null) {
throw new IllegalArgumentException("Service id " + idAsLong + " cannot be found.");
}
final Map<String, Object> model = new HashMap<>();
model.put("serviceName", r.getName());
model.put(STATUS, HttpServletResponse.SC_OK);
JsonUtils.render(model, response);
}
use of org.springframework.web.bind.annotation.PostMapping in project cas by apereo.
the class ECPProfileHandlerController method handleEcpRequest.
/**
* Handle ecp request.
*
* @param response the response
* @param request the request
* @throws Exception the exception
*/
@PostMapping(path = SamlIdPConstants.ENDPOINT_SAML2_IDP_ECP_PROFILE_SSO, consumes = { MediaType.TEXT_XML_VALUE, "application/vnd.paos.xml" })
public void handleEcpRequest(final HttpServletResponse response, final HttpServletRequest request) throws Exception {
final MessageContext soapContext = decodeSoapRequest(request);
final Credential credential = extractBasicAuthenticationCredential(request, response);
if (credential == null) {
LOGGER.error("Credentials could not be extracted from the SAML ECP request");
return;
}
if (soapContext == null) {
LOGGER.error("SAML ECP request could not be determined from the authentication request");
return;
}
handleEcpRequest(response, request, soapContext, credential);
}
Aggregations