Search in sources :

Example 1 with TaxonomyService

use of org.olat.modules.taxonomy.TaxonomyService in project OpenOLAT by OpenOLAT.

the class TaxonomyModuleWebService method getTaxonomyWebService.

@Path("{taxonomyKey}")
public TaxonomyWebService getTaxonomyWebService(@PathParam("taxonomyKey") Long taxonomyKey, @Context HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    if (!roles.isOLATAdmin()) {
        throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
    }
    if (taxonomyKey == null || taxonomyKey.longValue() <= 0) {
        throw new WebApplicationException(Response.serverError().status(Status.BAD_REQUEST).build());
    }
    TaxonomyService taxonomyService = CoreSpringFactory.getImpl(TaxonomyService.class);
    Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(taxonomyKey));
    if (taxonomy == null) {
        throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
    }
    return new TaxonomyWebService(taxonomy);
}
Also used : TaxonomyService(org.olat.modules.taxonomy.TaxonomyService) TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) WebApplicationException(javax.ws.rs.WebApplicationException) Taxonomy(org.olat.modules.taxonomy.Taxonomy) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) Path(javax.ws.rs.Path)

Example 2 with TaxonomyService

use of org.olat.modules.taxonomy.TaxonomyService in project OpenOLAT by OpenOLAT.

the class DocumentPoolModuleWebService method getTaxonomyWebService.

@Path("{taxonomyKey}")
public TaxonomyWebService getTaxonomyWebService(@PathParam("taxonomyKey") Long taxonomyKey, @Context HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    if (!roles.isOLATAdmin()) {
        throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
    }
    if (taxonomyKey == null || taxonomyKey.longValue() <= 0) {
        throw new WebApplicationException(Response.serverError().status(Status.BAD_REQUEST).build());
    }
    TaxonomyService taxonomyService = CoreSpringFactory.getImpl(TaxonomyService.class);
    Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(taxonomyKey));
    if (taxonomy == null) {
        throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
    }
    return new TaxonomyWebService(taxonomy);
}
Also used : TaxonomyService(org.olat.modules.taxonomy.TaxonomyService) TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) WebApplicationException(javax.ws.rs.WebApplicationException) Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyWebService(org.olat.modules.taxonomy.restapi.TaxonomyWebService) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) Path(javax.ws.rs.Path)

Example 3 with TaxonomyService

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

the class TaxonomyModuleWebService method getTaxonomyWebService.

@Path("{taxonomyKey}")
public TaxonomyWebService getTaxonomyWebService(@PathParam("taxonomyKey") Long taxonomyKey, @Context HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    if (!roles.isOLATAdmin()) {
        throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
    }
    if (taxonomyKey == null || taxonomyKey.longValue() <= 0) {
        throw new WebApplicationException(Response.serverError().status(Status.BAD_REQUEST).build());
    }
    TaxonomyService taxonomyService = CoreSpringFactory.getImpl(TaxonomyService.class);
    Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(taxonomyKey));
    if (taxonomy == null) {
        throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
    }
    return new TaxonomyWebService(taxonomy);
}
Also used : TaxonomyService(org.olat.modules.taxonomy.TaxonomyService) TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) WebApplicationException(javax.ws.rs.WebApplicationException) Taxonomy(org.olat.modules.taxonomy.Taxonomy) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) Path(javax.ws.rs.Path)

Example 4 with TaxonomyService

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

the class DocumentPoolModuleWebService method getTaxonomyWebService.

@Path("{taxonomyKey}")
public TaxonomyWebService getTaxonomyWebService(@PathParam("taxonomyKey") Long taxonomyKey, @Context HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    if (!roles.isOLATAdmin()) {
        throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
    }
    if (taxonomyKey == null || taxonomyKey.longValue() <= 0) {
        throw new WebApplicationException(Response.serverError().status(Status.BAD_REQUEST).build());
    }
    TaxonomyService taxonomyService = CoreSpringFactory.getImpl(TaxonomyService.class);
    Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(taxonomyKey));
    if (taxonomy == null) {
        throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
    }
    return new TaxonomyWebService(taxonomy);
}
Also used : TaxonomyService(org.olat.modules.taxonomy.TaxonomyService) TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) WebApplicationException(javax.ws.rs.WebApplicationException) Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyWebService(org.olat.modules.taxonomy.restapi.TaxonomyWebService) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) Path(javax.ws.rs.Path)

Aggregations

Path (javax.ws.rs.Path)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 Roles (org.olat.core.id.Roles)4 Taxonomy (org.olat.modules.taxonomy.Taxonomy)4 TaxonomyService (org.olat.modules.taxonomy.TaxonomyService)4 TaxonomyRefImpl (org.olat.modules.taxonomy.model.TaxonomyRefImpl)4 RestSecurityHelper.getRoles (org.olat.restapi.security.RestSecurityHelper.getRoles)4 TaxonomyWebService (org.olat.modules.taxonomy.restapi.TaxonomyWebService)2