Search in sources :

Example 11 with TaxonomyRefImpl

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

the class DocumentPoolWebDAVMergeSource method loadMergedContainers.

@Override
protected List<VFSContainer> loadMergedContainers() {
    List<VFSContainer> containers = new ArrayList<>();
    String taxonomyTreeKey = docPoolModule.getTaxonomyTreeKey();
    if (StringHelper.isLong(taxonomyTreeKey)) {
        Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(new Long(taxonomyTreeKey)));
        if (taxonomy != null) {
            String templatesDir = Util.createPackageTranslator(DocumentPoolMainController.class, identityEnv.getLocale()).translate("document.pool.templates");
            TaxonomyTreeBuilder builder = new TaxonomyTreeBuilder(taxonomy, identityEnv.getIdentity(), null, identityEnv.getRoles().isOLATAdmin(), docPoolModule.isTemplatesDirectoryEnabled(), templatesDir, null);
            TreeModel model = builder.buildTreeModel();
            TreeNode rootNode = model.getRootNode();
            for (int i = 0; i < rootNode.getChildCount(); i++) {
                VFSContainer container = loadRecursiveMergedContainers(taxonomy, rootNode.getChildAt(i));
                if (container != null) {
                    containers.add(container);
                }
            }
        }
    }
    return containers;
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) Taxonomy(org.olat.modules.taxonomy.Taxonomy) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) DocumentPoolMainController(org.olat.modules.docpool.ui.DocumentPoolMainController) TaxonomyTreeBuilder(org.olat.modules.taxonomy.manager.TaxonomyTreeBuilder)

Example 12 with TaxonomyRefImpl

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

the class PoolTaxonomySecurityCallback method isAllowedToLaunchSite.

@Override
public boolean isAllowedToLaunchSite(UserRequest ureq) {
    if (!questionPoolModule.isEnabled() || !StringHelper.isLong(questionPoolModule.getTaxonomyQPoolKey()) || ureq == null || ureq.getIdentity() == null) {
        return false;
    }
    UserSession usess = ureq.getUserSession();
    if (usess == null) {
        return false;
    }
    Roles roles = usess.getRoles();
    if (roles == null || roles.isInvitee() || roles.isGuestOnly()) {
        return false;
    }
    if (roles.isOLATAdmin() || roles.isPoolAdmin()) {
        return true;
    }
    TaxonomyCompetenceTypes[] types = new TaxonomyCompetenceTypes[] { TaxonomyCompetenceTypes.manage, TaxonomyCompetenceTypes.teach };
    TaxonomyRef taxonomy = new TaxonomyRefImpl(Long.valueOf(questionPoolModule.getTaxonomyQPoolKey()));
    return taxonomyService.hasTaxonomyCompetences(taxonomy, ureq.getIdentity(), new Date(), types);
}
Also used : TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) TaxonomyRef(org.olat.modules.taxonomy.TaxonomyRef) UserSession(org.olat.core.util.UserSession) Roles(org.olat.core.id.Roles) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) Date(java.util.Date)

Example 13 with TaxonomyRefImpl

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

the class PoolTaxonomySecurityCallback method isAllowedToLaunchSite.

@Override
public boolean isAllowedToLaunchSite(UserRequest ureq) {
    if (!questionPoolModule.isEnabled() || !StringHelper.isLong(questionPoolModule.getTaxonomyQPoolKey()) || ureq == null || ureq.getIdentity() == null) {
        return false;
    }
    UserSession usess = ureq.getUserSession();
    if (usess == null) {
        return false;
    }
    Roles roles = usess.getRoles();
    if (roles == null || roles.isInvitee() || roles.isGuestOnly()) {
        return false;
    }
    if (roles.isOLATAdmin() || roles.isPoolAdmin()) {
        return true;
    }
    TaxonomyCompetenceTypes[] types = new TaxonomyCompetenceTypes[] { TaxonomyCompetenceTypes.manage, TaxonomyCompetenceTypes.teach };
    TaxonomyRef taxonomy = new TaxonomyRefImpl(Long.valueOf(questionPoolModule.getTaxonomyQPoolKey()));
    return taxonomyService.hasTaxonomyCompetences(taxonomy, ureq.getIdentity(), new Date(), types);
}
Also used : TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) TaxonomyRef(org.olat.modules.taxonomy.TaxonomyRef) UserSession(org.olat.core.util.UserSession) Roles(org.olat.core.id.Roles) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) Date(java.util.Date)

Example 14 with TaxonomyRefImpl

use of org.olat.modules.taxonomy.model.TaxonomyRefImpl 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 15 with TaxonomyRefImpl

use of org.olat.modules.taxonomy.model.TaxonomyRefImpl 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

TaxonomyRefImpl (org.olat.modules.taxonomy.model.TaxonomyRefImpl)18 Taxonomy (org.olat.modules.taxonomy.Taxonomy)14 Roles (org.olat.core.id.Roles)10 TaxonomyService (org.olat.modules.taxonomy.TaxonomyService)8 Date (java.util.Date)4 Path (javax.ws.rs.Path)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 TreeModel (org.olat.core.gui.components.tree.TreeModel)4 Translator (org.olat.core.gui.translator.Translator)4 UserSession (org.olat.core.util.UserSession)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 TaxonomyRef (org.olat.modules.taxonomy.TaxonomyRef)4 DocumentPoolMainController (org.olat.modules.docpool.ui.DocumentPoolMainController)3 TaxonomyTreeBuilder (org.olat.modules.taxonomy.manager.TaxonomyTreeBuilder)3 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)3 RestSecurityHelper.getRoles (org.olat.restapi.security.RestSecurityHelper.getRoles)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Locale (java.util.Locale)2 BaseSecurity (org.olat.basesecurity.BaseSecurity)2