Search in sources :

Example 1 with TaxonomyCompetenceRefImpl

use of org.olat.modules.taxonomy.model.TaxonomyCompetenceRefImpl in project OpenOLAT by OpenOLAT.

the class TaxonomyWebService method removeTaxonomyLevelCompetence.

/**
 * Remove a competence.
 *
 * @response.representation.200.doc The competence was removed sucessfully
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The competence was not found
 * @param taxonomyKey The taxonomy tree
 * @param taxonomyLevelKey The taxonomy level
 * @param competenceKey The competence to remove
 * @param httpRequest  The HTTP request
 * @return Nothing
 */
@DELETE
@Path("levels/{taxonomyLevelKey}/competences/{competenceKey}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response removeTaxonomyLevelCompetence(@PathParam("taxonomyLevelKey") Long taxonomyLevelKey, @PathParam("competenceKey") Long competenceKey, @Context HttpServletRequest httpRequest) {
    Identity executor = getIdentity(httpRequest);
    TaxonomyCompetence competence = taxonomyService.getTaxonomyCompetence(new TaxonomyCompetenceRefImpl(competenceKey));
    if (competence == null || !competence.getTaxonomyLevel().getKey().equals(taxonomyLevelKey)) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    String before = taxonomyService.toAuditXml(competence);
    taxonomyService.removeTaxonomyLevelCompetence(competence);
    taxonomyService.auditLog(TaxonomyCompetenceAuditLog.Action.removeCompetence, before, null, null, taxonomy, competence, competence.getIdentity(), executor);
    return Response.ok().build();
}
Also used : TaxonomyCompetenceRefImpl(org.olat.modules.taxonomy.model.TaxonomyCompetenceRefImpl) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) Identity(org.olat.core.id.Identity) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes)

Example 2 with TaxonomyCompetenceRefImpl

use of org.olat.modules.taxonomy.model.TaxonomyCompetenceRefImpl in project openolat by klemens.

the class TaxonomyWebService method removeTaxonomyLevelCompetence.

/**
 * Remove a competence.
 *
 * @response.representation.200.doc The competence was removed sucessfully
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The competence was not found
 * @param taxonomyKey The taxonomy tree
 * @param taxonomyLevelKey The taxonomy level
 * @param competenceKey The competence to remove
 * @param httpRequest  The HTTP request
 * @return Nothing
 */
@DELETE
@Path("levels/{taxonomyLevelKey}/competences/{competenceKey}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response removeTaxonomyLevelCompetence(@PathParam("taxonomyLevelKey") Long taxonomyLevelKey, @PathParam("competenceKey") Long competenceKey, @Context HttpServletRequest httpRequest) {
    Identity executor = getIdentity(httpRequest);
    TaxonomyCompetence competence = taxonomyService.getTaxonomyCompetence(new TaxonomyCompetenceRefImpl(competenceKey));
    if (competence == null || !competence.getTaxonomyLevel().getKey().equals(taxonomyLevelKey)) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    String before = taxonomyService.toAuditXml(competence);
    taxonomyService.removeTaxonomyLevelCompetence(competence);
    taxonomyService.auditLog(TaxonomyCompetenceAuditLog.Action.removeCompetence, before, null, null, taxonomy, competence, competence.getIdentity(), executor);
    return Response.ok().build();
}
Also used : TaxonomyCompetenceRefImpl(org.olat.modules.taxonomy.model.TaxonomyCompetenceRefImpl) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) Identity(org.olat.core.id.Identity) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes)

Aggregations

Consumes (javax.ws.rs.Consumes)2 DELETE (javax.ws.rs.DELETE)2 Path (javax.ws.rs.Path)2 Identity (org.olat.core.id.Identity)2 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)2 TaxonomyCompetenceRefImpl (org.olat.modules.taxonomy.model.TaxonomyCompetenceRefImpl)2 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)2