Search in sources :

Example 1 with TaxonomyRefImpl

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

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

the class DocumentPoolSiteSecurityCallback method isAllowedToLaunchSite.

/**
 * @see com.frentix.olat.coursesite.SiteSecurityCallback#isAllowedToLaunchSite(org.olat.core.gui.UserRequest)
 */
@Override
public boolean isAllowedToLaunchSite(UserRequest ureq) {
    UserSession usess = ureq == null ? null : ureq.getUserSession();
    if (usess == null)
        return false;
    Roles roles = usess.getRoles();
    if (roles == null || roles.isInvitee() || roles.isGuestOnly()) {
        return false;
    }
    if (roles.isOLATAdmin()) {
        return true;
    }
    String taxonomyKey = docPoolModule.getTaxonomyTreeKey();
    if (StringHelper.isLong(taxonomyKey)) {
        TaxonomyRef taxonomy = new TaxonomyRefImpl(new Long(taxonomyKey));
        return taxonomyService.hasTaxonomyCompetences(taxonomy, ureq.getIdentity(), ureq.getRequestTimestamp());
    }
    return false;
}
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)

Example 3 with TaxonomyRefImpl

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

the class DocumentPoolAdminController method doOpenPermissions.

private void doOpenPermissions(UserRequest ureq) {
    removeAsListenerAndDispose(permissionsCtrl);
    if (StringHelper.containsNonWhitespace(docPoolModule.getTaxonomyTreeKey())) {
        WindowControl bwControl = addToHistory(ureq, OresHelper.createOLATResourceableType("Types"), null);
        Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(new Long(docPoolModule.getTaxonomyTreeKey())));
        permissionsCtrl = new DocumentPoolAdminPermissionsController(ureq, bwControl, taxonomy);
        listenTo(permissionsCtrl);
        mainVC.put("segmentCmp", permissionsCtrl.getInitialComponent());
    }
}
Also used : TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) Taxonomy(org.olat.modules.taxonomy.Taxonomy) WindowControl(org.olat.core.gui.control.WindowControl)

Example 4 with TaxonomyRefImpl

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

the class SearchControllerFactory method getBusinessPathLabel.

@Override
public String getBusinessPathLabel(String token, List<String> allTokens, Locale locale) {
    try {
        String[] splitted = token.split("[:]");
        if (splitted != null && splitted.length == 2) {
            String tokenType = splitted[0];
            String tokenKey = splitted[1];
            if ("RepositoryEntry".equals(tokenType)) {
                RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(Long.parseLong(tokenKey));
                return re.getDisplayname();
            }
            if ("CourseNode".equals(tokenType)) {
                String repoKey = allTokens.get(0).split("[:]")[1];
                RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(Long.parseLong(repoKey));
                if (re != null) {
                    ICourse course = CourseFactory.loadCourse(re);
                    CourseNode courseNode = course.getRunStructure().getNode(tokenKey);
                    return courseNode.getShortTitle();
                }
            }
            if ("Identity".equals(tokenType)) {
                IdentityShort identity = BaseSecurityManager.getInstance().loadIdentityShortByKey(Long.parseLong(tokenKey));
                return UserManager.getInstance().getUserDisplayName(identity);
            }
            if ("BusinessGroup".equals(tokenType)) {
                BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(Long.parseLong(tokenKey));
                return bg == null ? "" : bg.getName();
            }
            if ("Taxonomy".equals(tokenType)) {
                Taxonomy taxonomy = CoreSpringFactory.getImpl(TaxonomyService.class).getTaxonomy(new TaxonomyRefImpl(Long.parseLong(tokenKey)));
                return taxonomy == null ? "" : taxonomy.getDisplayName();
            }
            if ("TaxonomyLevel".equals(tokenType)) {
                TaxonomyLevel level = CoreSpringFactory.getImpl(TaxonomyService.class).getTaxonomyLevel(new TaxonomyLevelRefImpl(Long.parseLong(tokenKey)));
                return level == null ? "" : level.getDisplayName();
            }
            Translator translator = Util.createPackageTranslator(this.getClass(), locale);
            if ("DocumentPool".equals(tokenType)) {
                return translator.translate("DocumentPool");
            }
            if ("Templates".equals(tokenType)) {
                return translator.translate("Templates");
            }
            if ("userfolder".equals(tokenType)) {
                return translator.translate("type.identity.publicfolder");
            }
            String translated = translator.translate(tokenType);
            if (translated == null || translated.length() > 64) {
                // no translation, translator return an error
                return token;
            }
            return translated;
        }
    } catch (Exception ex) {
        log.warn("Problem to decipher business path token: " + token, ex);
    }
    return token;
}
Also used : TaxonomyService(org.olat.modules.taxonomy.TaxonomyService) TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) BusinessGroup(org.olat.group.BusinessGroup) Taxonomy(org.olat.modules.taxonomy.Taxonomy) IdentityShort(org.olat.basesecurity.IdentityShort) TaxonomyLevelRefImpl(org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) BusinessGroupService(org.olat.group.BusinessGroupService) Translator(org.olat.core.gui.translator.Translator) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) CourseNode(org.olat.course.nodes.CourseNode)

Example 5 with TaxonomyRefImpl

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

the class DocumentPoolSiteSecurityCallback method isAllowedToLaunchSite.

/**
 * @see com.frentix.olat.coursesite.SiteSecurityCallback#isAllowedToLaunchSite(org.olat.core.gui.UserRequest)
 */
@Override
public boolean isAllowedToLaunchSite(UserRequest ureq) {
    UserSession usess = ureq == null ? null : ureq.getUserSession();
    if (usess == null)
        return false;
    Roles roles = usess.getRoles();
    if (roles == null || roles.isInvitee() || roles.isGuestOnly()) {
        return false;
    }
    if (roles.isOLATAdmin()) {
        return true;
    }
    String taxonomyKey = docPoolModule.getTaxonomyTreeKey();
    if (StringHelper.isLong(taxonomyKey)) {
        TaxonomyRef taxonomy = new TaxonomyRefImpl(new Long(taxonomyKey));
        return taxonomyService.hasTaxonomyCompetences(taxonomy, ureq.getIdentity(), ureq.getRequestTimestamp());
    }
    return false;
}
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)

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