Search in sources :

Example 21 with PostMapping

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);
}
Also used : DataStatisticsEvent(org.hisp.dhis.datastatistics.DataStatisticsEvent) Date(java.util.Date) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 22 with PostMapping

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);
    }
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) HashMap(java.util.HashMap) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 23 with PostMapping

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);
}
Also used : RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) RegisteredService(org.apereo.cas.services.RegisteredService) HashMap(java.util.HashMap) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 24 with PostMapping

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);
}
Also used : RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) RegisteredService(org.apereo.cas.services.RegisteredService) HashMap(java.util.HashMap) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 25 with PostMapping

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);
}
Also used : UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Credential(org.apereo.cas.authentication.Credential) MessageContext(org.opensaml.messaging.context.MessageContext) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

PostMapping (org.springframework.web.bind.annotation.PostMapping)40 Profile (com.erudika.scoold.core.Profile)20 Post (com.erudika.scoold.core.Post)9 HashMap (java.util.HashMap)6 Report (com.erudika.scoold.core.Report)4 Map (java.util.Map)4 RegisteredService (org.apereo.cas.services.RegisteredService)4 ResponseEntity (org.springframework.http.ResponseEntity)4 Translation (com.erudika.para.core.Translation)3 Reply (com.erudika.scoold.core.Reply)3 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 Comment (com.erudika.scoold.core.Comment)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Locale (java.util.Locale)2 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)2